Class: ISO8601::Months
Overview
A Months atom in a Duration
A “calendar month” is the time interval resulting from the division of a “calendar year” in 12 time intervals.
A “duration month” is the duration of 28, 29, 30 or 31 “calendar days” depending on the start and/or the end of the corresponding time interval within the specific “calendar month”.
Instance Method Summary collapse
-
#factor ⇒ Object
The Month factor.
Methods inherited from Atom
#initialize, #to_i, #to_seconds
Constructor Details
This class inherits a constructor from ISO8601::Atom
Instance Method Details
#factor ⇒ Object
The Month factor
The “duration month” average is calculated through time intervals of 400 “duration years”. Each cycle of 400 “duration years” has 303 “common years” of 365 “calendar days” and 97 “leap years” of 366 “calendar days”.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/iso8601/atoms.rb', line 80 def factor if @base.nil? (((365 * 303 + 366 * 97) / 400) * 86400) / 12 elsif @atom == 0 month = (@base.month <= 12) ? (@base.month) : ((@base.month) % 12) year = @base.year + ((@base.month) / 12).to_i (Time.utc(year, month) - Time.utc(@base.year, @base.month)) else month = (@base.month + @atom <= 12) ? (@base.month + @atom) : ((@base.month + @atom) % 12) year = @base.year + ((@base.month + @atom) / 12).to_i (Time.utc(year, month) - Time.utc(@base.year, @base.month)) / @atom end end |