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 Attribute Summary
Attributes inherited from Atom
Instance Method Summary collapse
-
#factor ⇒ Integer
The Year factor.
-
#symbol ⇒ Symbol
The atom symbol.
Methods inherited from Atom
#==, #eql?, #hash, #initialize, #to_f, #to_i, #to_s, #to_seconds, #value
Constructor Details
This class inherits a constructor from ISO8601::Atom
Instance Method Details
#factor ⇒ Integer
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”.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/iso8601/atoms.rb', line 102 def factor if base.nil? ((365 * 303 + 366 * 97) / 400) * 86400 elsif atom.zero? 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 |
#symbol ⇒ Symbol
The atom symbol.
117 118 119 |
# File 'lib/iso8601/atoms.rb', line 117 def symbol :Y end |