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



45
46
47
# File 'lib/Duration/Months.rb', line 45

def to_days
  to_weeks.to_days
end

#to_fObject



62
63
64
# File 'lib/Duration/Months.rb', line 62

def to_f
  @months.to_f
end

#to_hoursObject



41
42
43
# File 'lib/Duration/Months.rb', line 41

def to_hours
  to_weeks.to_hours
end

#to_iObject



58
59
60
# File 'lib/Duration/Months.rb', line 58

def to_i
  @months.to_i
end

#to_microsecondsObject



25
26
27
# File 'lib/Duration/Months.rb', line 25

def to_microseconds
  to_weeks.to_microseconds
end

#to_millisecondsObject



29
30
31
# File 'lib/Duration/Months.rb', line 29

def to_milliseconds
  to_weeks.to_milliseconds
end

#to_minutesObject



37
38
39
# File 'lib/Duration/Months.rb', line 37

def to_minutes
  to_weeks.to_minutes
end

#to_monthsObject



54
55
56
# File 'lib/Duration/Months.rb', line 54

def to_months
  self
end

#to_nanosecondsObject



21
22
23
# File 'lib/Duration/Months.rb', line 21

def to_nanoseconds
  to_weeks.to_nanoseconds
end

#to_secondsObject



33
34
35
# File 'lib/Duration/Months.rb', line 33

def to_seconds
  to_weeks.to_seconds
end

#to_weeksObject



49
50
51
52
# File 'lib/Duration/Months.rb', line 49

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