WebRI  WebRI::TimeDelta

[Validate]
Generated with WebRI Redfish 1.2

TimeDelta

Constants

MINUTES
(Not documented)
HOURS
(Not documented)
DAYS
(Not documented)
WEEKS
(Not documented)
MONTHS
(Not documented)
YEARS
(Not documented)

Public Instance Methods

time_delta_string(seconds) click to toggle source

Return a string describing the amount of time in the given number of seconds in terms a human can understand easily.

# File lib/webri/generators/abstract/timedelta.rb, line 14
    def time_delta_string(seconds)
      return 'less than a minute' if seconds < MINUTES
      return (seconds / MINUTES).to_s + ' minute' + (seconds/60 == 1 ? '' : 's') if seconds < (50 * MINUTES)
      return 'about one hour' if seconds < (90 * MINUTES)
      return (seconds / HOURS).to_s + ' hours' if seconds < (18 * HOURS)
      return 'one day' if seconds < DAYS
      return 'about one day' if seconds < (2 * DAYS)
      return (seconds / DAYS).to_s + ' days' if seconds < WEEKS
      return 'about one week' if seconds < (2 * WEEKS)
      return (seconds / WEEKS).to_s + ' weeks' if seconds < (3 * MONTHS)
      return (seconds / MONTHS).to_s + ' months' if seconds < YEARS
      return (seconds / YEARS).to_s + ' years'
    end

Disabled; run with --debug to generate this.