Module: ThirdBase::DateTimeCompatInstanceMethods
- Included in:
- DateTime
- Defined in:
- lib/third_base/make_compat.rb
Instance Method Summary collapse
-
#asctime ⇒ Object
(also: #ctime)
Returns a formatted string representing the date.
- #day_fraction ⇒ Object
-
#new_offset(offset = 0) ⇒ Object
(also: #newof)
Returns a new DateTime with the same date and time as this datetime, but with a new offset.
-
#offset ⇒ Object
(also: #of)
Return the offset as a Float representing the fraction of the day different from UTC.
-
#offset_sec ⇒ Object
Return the offset as a number of seconds from UTC.
-
#sec_fraction ⇒ Object
The fraction of a second represented as a fraction of the entire day.
Instance Method Details
#asctime ⇒ Object Also known as: ctime
Returns a formatted string representing the date.
366 367 368 |
# File 'lib/third_base/make_compat.rb', line 366 def asctime strftime('%c') end |
#day_fraction ⇒ Object
371 372 373 |
# File 'lib/third_base/make_compat.rb', line 371 def day_fraction fract end |
#new_offset(offset = 0) ⇒ Object Also known as: newof
Returns a new DateTime with the same date and time as this datetime, but with a new offset.
376 377 378 |
# File 'lib/third_base/make_compat.rb', line 376 def new_offset(offset=0) self.class.new!(:civil=>civil, :parts=>time_parts, :offset=>(offset*86400).to_i) end |
#offset ⇒ Object Also known as: of
Return the offset as a Float representing the fraction of the day different from UTC.
382 383 384 |
# File 'lib/third_base/make_compat.rb', line 382 def offset @offset/86400.0 end |
#offset_sec ⇒ Object
Return the offset as a number of seconds from UTC.
388 389 390 |
# File 'lib/third_base/make_compat.rb', line 388 def offset_sec @offset end |
#sec_fraction ⇒ Object
The fraction of a second represented as a fraction of the entire day.
393 394 395 |
# File 'lib/third_base/make_compat.rb', line 393 def sec_fraction usec/86400000000.0 end |