module
TimeInWords::Helpers(T)
Extended Modules
Defined in:
time_in_words.crInstance Method Summary
-
#distance(*, from : Time, to : Time) : String
Returns a
Stringwith approximate distance in time between#fromandto. -
#distance(*, span : Time::Span) : String
Returns a
Stringwith approximate distance in time between#fromandto. -
#from(*, time : Time, now : Time = Time.utc) : String
Returns the approximate relative time based on elapsed duration.
Instance Method Detail
def distance(*, from : Time, to : Time) : String
#
Returns a String with approximate distance in time between #from and to.
distance_of_time_in_words(Time.utc(2019, 8, 14, 10, 0, 0), Time.utc(2019, 8, 14, 10, 0, 5))
# => "5 seconds"
distance_of_time_in_words(Time.utc(2019, 8, 14, 10, 0), Time.utc(2019, 8, 14, 10, 25))
# => "25 minutes"
distance_of_time_in_words(Time.utc(2019, 8, 14, 10), Time.utc(2019, 8, 14, 11))
# => "about an hour"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2019, 8, 16))
# => "2 days"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2019, 10, 4))
# => "about 2 months"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2061, 10, 4))
# => "about 42 years"
def distance(*, span : Time::Span) : String
#
Returns a String with approximate distance in time between #from and to.
distance_of_time_in_words(Time.utc(2019, 8, 14, 10, 0, 0), Time.utc(2019, 8, 14, 10, 0, 5))
# => "5 seconds"
distance_of_time_in_words(Time.utc(2019, 8, 14, 10, 0), Time.utc(2019, 8, 14, 10, 25))
# => "25 minutes"
distance_of_time_in_words(Time.utc(2019, 8, 14, 10), Time.utc(2019, 8, 14, 11))
# => "about an hour"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2019, 8, 16))
# => "2 days"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2019, 10, 4))
# => "about 2 months"
distance_of_time_in_words(Time.utc(2019, 8, 14), Time.utc(2061, 10, 4))
# => "about 42 years"
def from(*, time : Time, now : Time = Time.utc) : String
#
Returns the approximate relative time based on elapsed duration.