module

TimeFormat

Available methods (for convenience):

  • #auto
  • #minutes
  • #m
  • #seconds
  • #s
  • #milliseconds
  • #ms
  • #microseconds
  • #μs
  • #mcs (alias of #μs)

Instance methods

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
Source
m(time, round = 2)

Returns time in minutes in short human readable format

TimeFormat.m(5.minutes + 36.seconds + 175.milliseconds) # => 5.6m
Source
mcs(time : Float | Time::Span)

ditto

Source
microseconds(time : Float | Time::Span) : String

Returns time in microseconds in human readable format

TimeFormat.microseconds(5.minutes + 36.seconds + 175.milliseconds) # => 336175000 microseconds
Source
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
Source
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
Source
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
Source
s(time, round = 3)

Returns time in seconds in short human readable format

TimeFormat.s(5.minutes + 36.seconds + 175.milliseconds) # => 336.175s
Source
seconds(time, round = 3) : String

Returns time in seconds in human readable format

TimeFormat.seconds(5.minutes + 36.seconds + 175.milliseconds) # => 336.175 seconds
Source
μs(time : Float | Time::Span)

Returns time in microseconds in short human readable format

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