module TimeFormat

Overview

Available methods (for convenience):

Extended Modules

Defined in:

time_format.cr

Instance Method Summary

Instance Method Detail

def auto(time : Float | Time::Span, short = true) : String #

Returns time in human readable format based on how big it is

TimeFormat.auto(1.minute, false)    # => 1 minute
TimeFormat.auto(1.milliseconds / 2) # => 500μs

[View source]
def m(time, round = 2) #

Returns time in minutes in short human readable format

TimeFormat.m(5.minutes + 36.seconds + 175.milliseconds) # => 5.6m

[View source]
def mcs(time : Float | Time::Span) #

ditto


[View source]
def microseconds(time : Float | Time::Span) : String #

Returns time in microseconds in human readable format

TimeFormat.microseconds(5.minutes + 36.seconds + 175.milliseconds) # => 336175000 microseconds

[View source]
def milliseconds(time : Float | Time::Span, round : Int32 = 3) : String #

Returns time in milliseconds in human readable format

TimeFormat.milliseconds(5.minutes + 36.seconds + 175.milliseconds) # => 336175.0 milliseconds

[View source]
def minutes(time : Float | Time::Span, round : Int32 = 2) : String #

Returns time in minutes in human readable format

TimeFormat.minutes(5.minutes + 36.seconds + 175.milliseconds) # => 5.6 minutes

[View source]
def ms(time : Float | Time::Span, round : Int32 = 3) #

Returns time in milliseconds in short human readable format

TimeFormat.ms(5.minutes + 36.seconds + 175.milliseconds) # => 336175.0ms

[View source]
def s(time, round = 3) #

Returns time in seconds in short human readable format

TimeFormat.s(5.minutes + 36.seconds + 175.milliseconds) # => 336.175s

[View source]
def seconds(time, round = 3) : String #

Returns time in seconds in human readable format

TimeFormat.seconds(5.minutes + 36.seconds + 175.milliseconds) # => 336.175 seconds

[View source]
def μs(time : Float | Time::Span) #

Returns time in microseconds in short human readable format

TimeFormat.μs(5.minutes + 36.seconds + 175.milliseconds) # => 336175000μs

[View source]