Module: Darian
- Defined in:
- lib/darian.rb,
lib/darian/date.rb,
lib/darian/time.rb,
lib/darian/version.rb,
lib/darian/date_methods.rb
Overview
Common date methods for Time and Date classes.
Copyright © 2012 Andrey “A.I.” Sitnik <[email protected]>, sponsored by Evil Martians.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Modules: DateMethods Classes: Date, Time
Constant Summary collapse
- VERSION =
'0.1'.freeze
Class Method Summary collapse
-
.from_earth(arg) ⇒ Object
Convert ‘arg` to martian time or date, depend on `arg` class.
-
.now ⇒ Object
Return current Mars time.
-
.today ⇒ Object
Return current Mars date.
Class Method Details
.from_earth(arg) ⇒ Object
Convert ‘arg` to martian time or date, depend on `arg` class.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/darian.rb', line 35 def from_earth(arg) if arg.is_a? ::Time Darian::Time.from_earth(arg) elsif arg.is_a? ::DateTime Darian::Time.from_earth(::Time.parse(arg.to_s)) elsif arg.is_a? ::Date Darian::Date.from_earth(arg) else raise ArgumentError, "Can't convert #{arg.class} to martian time or date" end end |
.now ⇒ Object
Return current Mars time. Shortcut for ‘Darian.from_earth(Time.now)`.
48 49 50 |
# File 'lib/darian.rb', line 48 def now Darian::Time.from_earth(::Time.now) end |
.today ⇒ Object
Return current Mars date. Shortcut for ‘Darian.from_earth(Date.today)`.
53 54 55 |
# File 'lib/darian.rb', line 53 def today Darian::Date.from_earth(::Date.today) end |