struct

Time::Span

Inherits Steppable < Comparable < Struct < Value < Object

Extensions to the stdlib Time::Span struct.

Instance methods

humanize(io : IO)

Humanize the time span, writing it into io. This method does not know about units other than second and its fractions.

1.second.humanize(STDOUT)         # => 1.0s
500.milliseconds.humanize(STDOUT) # => 500ms
5.minutes.humanize(STDOUT)        # => 300s
10.hours.humanize(STDOUT)         # => 36,000s

It's based on Johannes Müller's code found in crystal/src/benchmark/ips.cr.

Source
humanize

Humanize the time span, returning a String in human-readable format. See #humanize(io).

Source