Class: Duration::Months

Inherits:
Object
  • Object
show all
Includes:
Common, Relative
Defined in:
lib/Duration/Months.rb

Overview

A month is not a fixed quantity: its length depends on the calendar. The conversions below use the Gregorian mean month (2629746 seconds), so they are honest only as a statistical average, never as calendar-correct arithmetic. For that, reach for a calendar-anchored type such as month.rb.

ago and hence (via Relative) inherit the same caveat: they displace by the mean month rather than an actual calendar month, so they are approximate, not calendar-correct. Months is slated for removal in 0.5.0.

Instance Method Summary collapse

Methods included from Relative

#ago, #hence

Methods included from Common

#*, #+, #-, #/, #<=>

Instance Method Details

#to_daysObject



43
44
45
# File 'lib/Duration/Months.rb', line 43

def to_days
  to_weeks.to_days
end

#to_fObject



60
61
62
# File 'lib/Duration/Months.rb', line 60

def to_f
  @months.to_f
end

#to_hoursObject



39
40
41
# File 'lib/Duration/Months.rb', line 39

def to_hours
  to_weeks.to_hours
end

#to_iObject



56
57
58
# File 'lib/Duration/Months.rb', line 56

def to_i
  @months.to_i
end

#to_microsecondsObject



23
24
25
# File 'lib/Duration/Months.rb', line 23

def to_microseconds
  to_weeks.to_microseconds
end

#to_millisecondsObject



27
28
29
# File 'lib/Duration/Months.rb', line 27

def to_milliseconds
  to_weeks.to_milliseconds
end

#to_minutesObject



35
36
37
# File 'lib/Duration/Months.rb', line 35

def to_minutes
  to_weeks.to_minutes
end

#to_monthsObject



52
53
54
# File 'lib/Duration/Months.rb', line 52

def to_months
  self
end

#to_nanosecondsObject



19
20
21
# File 'lib/Duration/Months.rb', line 19

def to_nanoseconds
  to_weeks.to_nanoseconds
end

#to_secondsObject



31
32
33
# File 'lib/Duration/Months.rb', line 31

def to_seconds
  to_weeks.to_seconds
end

#to_weeksObject



47
48
49
50
# File 'lib/Duration/Months.rb', line 47

def to_weeks
  # A month is the Gregorian mean: 2629746 seconds against 604800 per week.
  Duration::Weeks.new(@months * 2629746 / 604800r)
end