Module: ThirdBase::DateTime::ClassMethods
- Included in:
- ThirdBase::DateTime
- Defined in:
- lib/third_base/datetime.rb
Instance Method Summary collapse
-
#civil(year, mon, day, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given year, month, day of month, hour, minute, second, microsecond and offset.
-
#commercial(cwyear, cweek, cwday = 5, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given commercial week year, commercial week, commercial week day, hour, minute second, microsecond, and offset.
-
#jd(jd, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given julian date, hour, minute, second, microsecond, and offset.
-
#jd_fract(jd, fract = 0.0, offset = 0) ⇒ Object
Create a new DateTime with the given julian day, fraction of the day (0.5 is Noon), and offset.
-
#now ⇒ Object
Create a new DateTime with the current date and time.
-
#ordinal(year, yday, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given year, day of year, hour, minute, second, microsecond, and offset.
Instance Method Details
#civil(year, mon, day, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given year, month, day of month, hour, minute, second, microsecond and offset.
73 74 75 |
# File 'lib/third_base/datetime.rb', line 73 def civil(year, mon, day, hour=0, min=0, sec=0, usec=0, offset=0) new!(:civil=>[year, mon, day], :parts=>[hour, min, sec, usec], :offset=>offset) end |
#commercial(cwyear, cweek, cwday = 5, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given commercial week year, commercial week, commercial week day, hour, minute second, microsecond, and offset.
79 80 81 |
# File 'lib/third_base/datetime.rb', line 79 def commercial(cwyear, cweek, cwday=5, hour=0, min=0, sec=0, usec=0, offset=0) new!(:commercial=>[cwyear, cweek, cwday], :parts=>[hour, min, sec, usec], :offset=>offset) end |
#jd(jd, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given julian date, hour, minute, second, microsecond, and offset.
84 85 86 |
# File 'lib/third_base/datetime.rb', line 84 def jd(jd, hour=0, min=0, sec=0, usec=0, offset=0) new!(:jd=>jd, :parts=>[hour, min, sec, usec], :offset=>offset) end |
#jd_fract(jd, fract = 0.0, offset = 0) ⇒ Object
Create a new DateTime with the given julian day, fraction of the day (0.5 is Noon), and offset.
89 90 91 |
# File 'lib/third_base/datetime.rb', line 89 def jd_fract(jd, fract=0.0, offset=0) new!(:jd=>jd, :fract=>fract, :offset=>offset) end |
#now ⇒ Object
Create a new DateTime with the current date and time.
94 95 96 97 |
# File 'lib/third_base/datetime.rb', line 94 def now t = Time.now new!(:civil=>[t.year, t.mon, t.day], :parts=>[t.hour, t.min, t.sec, t.usec], :offset=>t.utc_offset) end |
#ordinal(year, yday, hour = 0, min = 0, sec = 0, usec = 0, offset = 0) ⇒ Object
Create a new DateTime with the given year, day of year, hour, minute, second, microsecond, and offset.
100 101 102 |
# File 'lib/third_base/datetime.rb', line 100 def ordinal(year, yday, hour=0, min=0, sec=0, usec=0, offset=0) new!(:ordinal=>[year, yday], :parts=>[hour, min, sec, usec], :offset=>offset) end |