Class: Darian::Date
Overview
Darian Mars calendar date converter.
mars = Darian::Date.from_earth(Date.today)
puts mars
puts mars.month_name
Instance Attribute Summary
Attributes included from DateMethods
#month, #month_of_season, #season, #sol, #sol_of_season, #week_sol, #year
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time) ⇒ Date
constructor
Create martian date by time.
-
#to_s ⇒ Object
Printable string of martian date.
Methods included from DateMethods
Constructor Details
#initialize(time) ⇒ Date
Create martian date by time.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/darian/date.rb', line 36 def initialize(time) @year = time.year @month = time.month @sol = time.sol @week_sol = time.week_sol @season = time.season @sol_of_season = time.sol_of_season @month_of_season = time.month_of_season end |
Class Method Details
.from_earth(date) ⇒ Object
30 31 32 33 |
# File 'lib/darian/date.rb', line 30 def self.from_earth(date) time = ::Time.parse(date.to_s + " 00:00:00") ::Darian::Time.from_earth(time).to_date end |
Instance Method Details
#to_s ⇒ Object
Printable string of martian date.
48 49 50 |
# File 'lib/darian/date.rb', line 48 def to_s sprintf '%d-%02d-%02d', @year, @month, @sol end |