struct Time::Span
- Time::Span
- Struct
- Value
- Object
Overview
Extensions to the stdlib Time::Span
struct.
Included Modules
- Comparable(Time::Span)
- Steppable
Defined in:
time-span-humanize.crInstance Method Summary
-
#humanize(io : IO)
Humanize the time span, writing it into io.
-
#humanize
Humanize the time span, returning a
String
in human-readable format.
Instance Method Detail
def 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
.
def humanize
#
Humanize the time span, returning a String
in human-readable format.
See #humanize(io)
.