Module: ThirdBase::DateTimeCompatClassMethods
- Included in:
- DateTime
- Defined in:
- lib/third_base/make_compat.rb
Overview
ThirdBase’s top level DateTime compatibility class, striving to be as close as possible to the standard DateTime class’s API.
Instance Method Summary collapse
-
#_strptime(str, fmt = '%FT%T%z') ⇒ Object
Parse the datetime using strptime with the given format.
-
#civil(year = -4712,, mon = 1, day = 1, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given year, month, day of month, hour, minute, second, and offset, ignores sg.
-
#commercial(cwyear = 1582, cweek = 41, cwday = 5, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given commercial week year, commercial week, commercial week day, hour, minute, second, and offset, ignores sg.
-
#jd(j = 0, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given julian date, hour, minute, second, and offset, ignores sg.
-
#now(sg = nil) ⇒ Object
Creates a new DateTime with the current date and time, ignores sg.
-
#ordinal(year = -4712,, yday = 1, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given year, day of year, hour, minute, second, and offset, ignores sg.
-
#parse(str = "-4712-01-01T00:00:00+00:00", comp = false, sg = nil) ⇒ Object
Parse given string using ThirdBase::DateTime’s date parser, ignores comp and sg.
-
#strptime(str = "-4712-01-01T00:00:00+00:00", fmt = '%FT%T%z', sg = nil) ⇒ Object
Parse given string using given format, ignores sg.
Instance Method Details
#_strptime(str, fmt = '%FT%T%z') ⇒ Object
Parse the datetime using strptime with the given format.
323 324 325 |
# File 'lib/third_base/make_compat.rb', line 323 def _strptime(str, fmt='%FT%T%z') strptime(str, fmt) end |
#civil(year = -4712,, mon = 1, day = 1, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given year, month, day of month, hour, minute, second, and offset, ignores sg.
328 329 330 |
# File 'lib/third_base/make_compat.rb', line 328 def civil(year=-4712, mon=1, day=1, hour=0, min=0, sec=0, offset=0, sg=nil) super(year, mon, day, hour, min, sec, 0, (offset*86400).to_i) end |
#commercial(cwyear = 1582, cweek = 41, cwday = 5, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given commercial week year, commercial week, commercial week day, hour, minute, second, and offset, ignores sg.
334 335 336 |
# File 'lib/third_base/make_compat.rb', line 334 def commercial(cwyear=1582, cweek=41, cwday=5, hour=0, min=0, sec=0, offset=0, sg=nil) super(cwyear, cweek, cwday, hour, min, sec, 0, (offset*86400).to_i) end |
#jd(j = 0, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given julian date, hour, minute, second, and offset, ignores sg.
339 340 341 |
# File 'lib/third_base/make_compat.rb', line 339 def jd(j=0, hour=0, min=0, sec=0, offset=0, sg=nil) super(j, hour, min, sec, 0, (offset*86400).to_i) end |
#now(sg = nil) ⇒ Object
Creates a new DateTime with the current date and time, ignores sg.
359 360 361 |
# File 'lib/third_base/make_compat.rb', line 359 def now(sg=nil) super() end |
#ordinal(year = -4712,, yday = 1, hour = 0, min = 0, sec = 0, offset = 0, sg = nil) ⇒ Object
Creates a new DateTime with the given year, day of year, hour, minute, second, and offset, ignores sg.
344 345 346 |
# File 'lib/third_base/make_compat.rb', line 344 def ordinal(year=-4712, yday=1, hour=0, min=0, sec=0, offset=0, sg=nil) super(year, yday, hour, min, sec, 0, (offset*86400).to_i) end |
#parse(str = "-4712-01-01T00:00:00+00:00", comp = false, sg = nil) ⇒ Object
Parse given string using ThirdBase::DateTime’s date parser, ignores comp and sg.
349 350 351 |
# File 'lib/third_base/make_compat.rb', line 349 def parse(str="-4712-01-01T00:00:00+00:00", comp=false, sg=nil) super(str) end |
#strptime(str = "-4712-01-01T00:00:00+00:00", fmt = '%FT%T%z', sg = nil) ⇒ Object
Parse given string using given format, ignores sg.
354 355 356 |
# File 'lib/third_base/make_compat.rb', line 354 def strptime(str="-4712-01-01T00:00:00+00:00", fmt='%FT%T%z', sg=nil) super(str, fmt) end |