Class: ISO8601::Years
Overview
A Years atom in a Duration
A “calendar year” is the cyclic time interval in a calendar which is required for one revolution of the Earth around the Sun and approximated to an integral number of “calendar days”.
A “duration year” is the duration of 365 or 366 “calendar days” depending on the start and/or the end of the corresponding time interval within the specific “calendar year”.
Instance Method Summary collapse
-
#factor ⇒ Object
The Year 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 Year factor
The “duration year” 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”.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/iso8601/atoms.rb', line 52 def factor if @base.nil? ((365 * 303 + 366 * 97) / 400) * 86400 elsif @atom == 0 year = (@base.year).to_i (::Time.utc(year) - ::Time.utc(@base.year)) else year = (@base.year + @atom).to_i (::Time.utc(year) - ::Time.utc(@base.year)) / @atom end end |