Class: DateTime
- Defined in:
- opal/stdlib/date/date_time.rb,
opal/stdlib/date/formatters.rb
Constant Summary
Constants inherited from Date
Date::ABBR_DAYNAMES , Date::ABBR_MONTHNAMES , Date::DAYNAMES , Date::ENGLAND , Date::GREGORIAN , Date::ITALY , Date::JULIAN , Date::MONTHNAMES
Instance Attribute Summary
Attributes inherited from Date
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
-
#initialize(year = -4712,, month = 1, day = 1, hours = 0, minutes = 0, seconds = 0, offset = 0, start = ITALY) ⇒ DateTime
constructor
A new instance of DateTime.
- #new_offset(offset) ⇒ Object
- #offset ⇒ Object
- #sec_fraction ⇒ Object (also: #second_fraction)
- #to_date ⇒ Object
- #to_datetime ⇒ Object
- #to_time ⇒ Object
Methods inherited from Date
#<< , #<=> , #>> , _days_in_month , #as_json , #clone , #cwday , #cweek , def_formatter , #downto , gregorian_leap? , #jd , #julian? , #new_start , #next , #next_day , #next_month , #next_year , #prev_day , #prev_month , #prev_year , #step , #strftime , #to_json , #to_n , today , #upto , wrap
Methods included from Forwardable
#def_instance_delegator , #def_instance_delegators , #instance_delegate
Constructor Details
#initialize(year = -4712,, month = 1, day = 1, hours = 0, minutes = 0, seconds = 0, offset = 0, start = ITALY) ⇒ DateTime
Returns a new instance of DateTime.
12 13 14 15 16 17 18 19 20 21 22 23
# File 'opal/stdlib/date/date_time.rb', line 12 def initialize(year = -4712, month = 1, day = 1, hours = 0, minutes = 0, seconds = 0, offset = 0, start = ITALY ) %x{ // Because of Gregorian reform calendar goes from 1582年10月04日 to 1582年10月15日. // All days in between end up as 4 october. if (year === 1582 && month === 10 && day > 4 && day < 15) { day = 4; } } @date = Time .new(year, month, day, hours, minutes, seconds, offset) @start = start end
Class Method Details
Instance Method Details
#+(other) ⇒ Object
#-(other) ⇒ Object
#new_offset(offset) ⇒ Object
53 54 55 56 57 58
# File 'opal/stdlib/date/date_time.rb', line 53 def new_offset(offset) new_date = clone offset = Time ._parse_offset(offset) `new_date.date.timezone = offset` new_date end
#offset ⇒ Object
35 36 37
# File 'opal/stdlib/date/date_time.rb', line 35 def offset @date.gmt_offset / (24 * 3600r) end
#sec_fraction ⇒ Object Also known as: second_fraction
29 30 31
# File 'opal/stdlib/date/date_time.rb', line 29 def sec_fraction @date.usec / 1_000_000r end
#to_date ⇒ Object
#to_datetime ⇒ Object
60 61 62
# File 'opal/stdlib/date/date_time.rb', line 60 def to_datetime self end
#to_time ⇒ Object
64 65 66
# File 'opal/stdlib/date/date_time.rb', line 64 def to_time @date.dup end