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”.
Constant Summary collapse
- AVERAGE_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”.
Years::AVERAGE_FACTOR / 12
Instance Attribute Summary
Attributes included from Atomic
Instance Method Summary collapse
-
#factor(base = nil) ⇒ Numeric
The Month factor.
-
#initialize(atom) ⇒ Months
constructor
A new instance of Months.
-
#symbol ⇒ Symbol
The atom symbol.
-
#to_seconds(base = nil) ⇒ Numeric
The amount of seconds.
Methods included from Atomic
#<=>, #eql?, #hash, #to_f, #to_i, #to_s, #valid_atom?, #valid_base?, #value
Constructor Details
#initialize(atom) ⇒ Months
Returns a new instance of Months.
24 25 26 27 28 |
# File 'lib/iso8601/months.rb', line 24 def initialize(atom) valid_atom?(atom) @atom = atom end |
Instance Method Details
#factor(base = nil) ⇒ Numeric
The Month factor
37 38 39 40 41 42 |
# File 'lib/iso8601/months.rb', line 37 def factor(base = nil) return AVERAGE_FACTOR if base.nil? return calculation(1, base) if atom.zero? calculation(atom, base) end |
#symbol ⇒ Symbol
The atom symbol.
59 60 61 |
# File 'lib/iso8601/months.rb', line 59 def symbol :M end |
#to_seconds(base = nil) ⇒ Numeric
The amount of seconds
51 52 53 |
# File 'lib/iso8601/months.rb', line 51 def to_seconds(base = nil) factor(base) * atom end |