Class: DateTime

Inherits:
Date show all
Defined in:
lib/framework/dateOrig.rb,
lib/framework/dateME.rb,
lib/framework/dateOrig.rb,
lib/framework/date/format.rb,
lib/framework/autocomplete/DateTime.rb

Overview

It is auto-generated content. Do not do required for this file in your application.

Defined Under Namespace

Modules: Format

Constant Summary

Constants inherited from Date

Date::ABBR_DAYNAMES, Date::ABBR_MONTHNAMES, Date::DATE_FORMATS, Date::DAYNAMES, Date::ENGLAND, Date::GREGORIAN, Date::HALF_DAYS_IN_DAY, Date::HOURS_IN_DAY, Date::ITALY, Date::JULIAN, Date::LD_EPOCH_IN_CJD, Date::MILLISECONDS_IN_DAY, Date::MILLISECONDS_IN_SECOND, Date::MINUTES_IN_DAY, Date::MJD_EPOCH_IN_AJD, Date::MJD_EPOCH_IN_CJD, Date::MONTHNAMES, Date::NANOSECONDS_IN_DAY, Date::NANOSECONDS_IN_SECOND, Date::SECONDS_IN_DAY, Date::UNIX_EPOCH_IN_AJD, Date::UNIX_EPOCH_IN_CJD

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Date

#+, #-, #<<, #<=>, #===, #>>, #_get_date, _httpdate, _iso8601, _jisx0301, _parse, _rfc2822, _rfc3339, _rfc822, _xmlschema, #ajd, #amjd, #asctime, #ctime, #cwday, #cweek, #cwyear, #day_fraction, #downto, #england, #eql?, #gregorian, #gregorian?, gregorian_leap?, #hash, #httpdate, #inspect, #italy, #jd, #julian, #julian?, julian_leap?, #ld, #leap?, #marshal_dump, #marshal_load, #mjd, #new_start, #next, #next_day, #next_month, #next_year, #old_strftime, once, #prev_day, #prev_month, #prev_year, #rfc2822, #rfc822, #start, #step, #to_formatted_s, today, #upto, valid_civil?, valid_commercial?, valid_jd?, valid_ordinal?, #yday

Methods included from Comparable

#<, #<=, #==, #>, #>=, #between?

Constructor Details

#initialize(time) ⇒ DateTime

Returns a new instance of DateTime.



211
212
213
# File 'lib/framework/dateME.rb', line 211

def initialize( time )
  @m_time = time
end

Class Method Details

._strptime(str, fmt) ⇒ Object



1289
1290
1291
# File 'lib/framework/date/format.rb', line 1289

def self._strptime(str, fmt='%FT%T%z')
  super(str, fmt)
end

.civil(y = -4712,, m = 1, d = 1, h = 0, min = 0, s = 0, of = 0, sg = ITALY) ⇒ Object Also known as: new

Create a new DateTime object corresponding to the specified Civil Date and hour h, minute min, second s.

The 24-hour clock is used. Negative values of h, min, and sec are treating as counting backwards from the end of the next larger unit (e.g. a min of -2 is treated as 58). No wraparound is performed. If an invalid time portion is specified, an ArgumentError is raised.

of is the offset from UTC as a fraction of a day (defaults to 0). sg specifies the Day of Calendar Reform.

y defaults to -4712, m to 1, and d to 1; this is Julian Day Number day 0. The time values default to 0.



1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
# File 'lib/framework/dateOrig.rb', line 1632

def self.civil(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
  unless (jd = _valid_civil?(y, m, d, sg)) &&
  (fr = _valid_time?(h, min, s))
    raise ArgumentError, 'invalid date'
  end
  if String === of
    of = Rational(zone_to_diff(of) || 0, 86400)
  end
  new!(jd_to_ajd(jd, fr, of), of, sg)
end

.commercial(y = -4712,, w = 1, d = 1, h = 0, min = 0, s = 0, of = 0, sg = ITALY) ⇒ Object

Create a new DateTime object corresponding to the specified Commercial Date and hour h, minute min, second s.

The 24-hour clock is used. Negative values of h, min, and sec are treating as counting backwards from the end of the next larger unit (e.g. a min of -2 is treated as 58). No wraparound is performed. If an invalid time portion is specified, an ArgumentError is raised.

of is the offset from UTC as a fraction of a day (defaults to 0). sg specifies the Day of Calendar Reform.

y defaults to -4712, w to 1, and d to 1; this is Julian Day Number day 0. The time values default to 0.



1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
# File 'lib/framework/dateOrig.rb', line 1660

def self.commercial(y=-4712, w=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
  unless (jd = _valid_commercial?(y, w, d, sg)) &&
  (fr = _valid_time?(h, min, s))
    raise ArgumentError, 'invalid date'
  end
  if String === of
    of = Rational(zone_to_diff(of) || 0, 86400)
  end
  new!(jd_to_ajd(jd, fr, of), of, sg)
end

.httpdate(str = 'Mon, 01 Jan -4712 00:00:00 GMT', sg = ITALY) ⇒ Object

:nodoc:



1772
1773
1774
1775
# File 'lib/framework/dateOrig.rb', line 1772

def self.httpdate(str='Mon, 01 Jan -4712 00:00:00 GMT', sg=ITALY) # :nodoc:
  elem = _httpdate(str)
  new_by_frags(elem, sg)
end

.iso8601(str = '-4712-01-01T00:00:00+00:00', sg = ITALY) ⇒ Object

:nodoc:



1750
1751
1752
1753
# File 'lib/framework/dateOrig.rb', line 1750

def self.iso8601(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
  elem = _iso8601(str)
  new_by_frags(elem, sg)
end

.jd(jd = 0, h = 0, min = 0, s = 0, of = 0, sg = ITALY) ⇒ Object

Create a new DateTime object corresponding to the specified Julian Day Number jd and hour h, minute min, second s.

The 24-hour clock is used. Negative values of h, min, and sec are treating as counting backwards from the end of the next larger unit (e.g. a min of -2 is treated as 58). No wraparound is performed. If an invalid time portion is specified, an ArgumentError is raised.

of is the offset from UTC as a fraction of a day (defaults to 0). sg specifies the Day of Calendar Reform.

All day/time values default to 0.



1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
# File 'lib/framework/dateOrig.rb', line 1582

def self.jd(jd=0, h=0, min=0, s=0, of=0, sg=ITALY)
  unless (jd = _valid_jd?(jd, sg)) &&
  (fr = _valid_time?(h, min, s))
    raise ArgumentError, 'invalid date'
  end
  if String === of
    of = Rational(zone_to_diff(of) || 0, 86400)
  end
  new!(jd_to_ajd(jd, fr, of), of, sg)
end

.jisx0301(str = '-4712-01-01T00:00:00+00:00', sg = ITALY) ⇒ Object

:nodoc:



1777
1778
1779
1780
# File 'lib/framework/dateOrig.rb', line 1777

def self.jisx0301(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
  elem = _jisx0301(str)
  new_by_frags(elem, sg)
end

.ordinal(y = -4712,, d = 1, h = 0, min = 0, s = 0, of = 0, sg = ITALY) ⇒ Object

Create a new DateTime object corresponding to the specified Ordinal Date and hour h, minute min, second s.

The 24-hour clock is used. Negative values of h, min, and sec are treating as counting backwards from the end of the next larger unit (e.g. a min of -2 is treated as 58). No wraparound is performed. If an invalid time portion is specified, an ArgumentError is raised.

of is the offset from UTC as a fraction of a day (defaults to 0). sg specifies the Day of Calendar Reform.

y defaults to -4712, and d to 1; this is Julian Day Number day 0. The time values default to 0.



1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
# File 'lib/framework/dateOrig.rb', line 1607

def self.ordinal(y=-4712, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
  unless (jd = _valid_ordinal?(y, d, sg)) &&
  (fr = _valid_time?(h, min, s))
    raise ArgumentError, 'invalid date'
  end
  if String === of
    of = Rational(zone_to_diff(of) || 0, 86400)
  end
  new!(jd_to_ajd(jd, fr, of), of, sg)
end

.parse(str = '-4712-01-01T00:00:00+00:00', comp = true, sg = ITALY) ⇒ Object

Create a new DateTime object by parsing from a String, without specifying the format.

str is a String holding a date-time representation. comp specifies whether to interpret 2-digit years as 19XX (>= 69) or 20XX (< 69); the default is not to. The method will attempt to parse a date-time from the String using various heuristics; see #_parse in date/format.rb for more details. If parsing fails, an ArgumentError will be raised.

The default str is ‘-4712-01-01T00:00:00+00:00’; this is Julian Day Number day 0.

sg specifies the Day of Calendar Reform.



1745
1746
1747
1748
# File 'lib/framework/dateOrig.rb', line 1745

def self.parse(str='-4712-01-01T00:00:00+00:00', comp=true, sg=ITALY)
  elem = _parse(str, comp)
  new_by_frags(elem, sg)
end

.rfc2822(str = 'Mon, 1 Jan -4712 00:00:00 +0000', sg = ITALY) ⇒ Object Also known as: rfc822

:nodoc:



1765
1766
1767
1768
# File 'lib/framework/dateOrig.rb', line 1765

def self.rfc2822(str='Mon, 1 Jan -4712 00:00:00 +0000', sg=ITALY) # :nodoc:
  elem = _rfc2822(str)
  new_by_frags(elem, sg)
end

.rfc3339(str = '-4712-01-01T00:00:00+00:00', sg = ITALY) ⇒ Object

:nodoc:



1755
1756
1757
1758
# File 'lib/framework/dateOrig.rb', line 1755

def self.rfc3339(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
  elem = _rfc3339(str)
  new_by_frags(elem, sg)
end

.strptime(str = '-4712-01-01T00:00:00+00:00', fmt = '%FT%T%z', sg = ITALY) ⇒ Object

Create a new DateTime object by parsing from a String according to a specified format.

str is a String holding a date-time representation. fmt is the format that the date-time is in. See date/format.rb for details on supported formats.

The default str is ‘-4712-01-01T00:00:00+00:00’, and the default fmt is ‘%FT%T%z’. This gives midnight on Julian Day Number day 0.

sg specifies the Day of Calendar Reform.

An ArgumentError will be raised if str cannot be parsed.



1725
1726
1727
1728
# File 'lib/framework/dateOrig.rb', line 1725

def self.strptime(str='-4712-01-01T00:00:00+00:00', fmt='%FT%T%z', sg=ITALY)
  elem = _strptime(str, fmt)
  new_by_frags(elem, sg)
end

.xmlschema(str = '-4712-01-01T00:00:00+00:00', sg = ITALY) ⇒ Object

:nodoc:



1760
1761
1762
1763
# File 'lib/framework/dateOrig.rb', line 1760

def self.xmlschema(str='-4712-01-01T00:00:00+00:00', sg=ITALY) # :nodoc:
  elem = _xmlschema(str)
  new_by_frags(elem, sg)
end

Instance Method Details

#hourObject



204
# File 'lib/framework/dateME.rb', line 204

def hour() @m_time.hour end

#iso8601(n) ⇒ Object



1305
1306
1307
# File 'lib/framework/date/format.rb', line 1305

def iso8601(n=0)
  super() + iso8601_timediv(n)
end

#jisx0301(n) ⇒ Object



1313
1314
1315
# File 'lib/framework/date/format.rb', line 1313

def jisx0301(n=0)
  super() + iso8601_timediv(n)
end

#mdayObject



203
# File 'lib/framework/dateME.rb', line 203

def mday() @m_time.mday end

#minObject



205
# File 'lib/framework/dateME.rb', line 205

def min() @m_time.min end

#monObject



201
# File 'lib/framework/dateME.rb', line 201

def mon() @m_time.mon end

#offsetObject



207
208
209
# File 'lib/framework/dateME.rb', line 207

def offset() 
  of = Rational(@m_time.gmt_offset() || 0, 86400)
end

#rfc3339(n) ⇒ Object



1309
# File 'lib/framework/date/format.rb', line 1309

def rfc3339(n=0) iso8601(n) end

#secObject



206
# File 'lib/framework/dateME.rb', line 206

def sec() @m_time.sec end

#strftime(fmt) ⇒ Object



1285
1286
1287
# File 'lib/framework/date/format.rb', line 1285

def strftime(fmt='%FT%T%:z')
  super(fmt)
end

#to_dateObject



1859
# File 'lib/framework/dateOrig.rb', line 1859

def to_date() Date.new!(jd_to_ajd(jd, 0, 0), 0, @sg) end

#to_datetimeObject



215
# File 'lib/framework/dateME.rb', line 215

def to_datetime() self end

#to_sObject

4p



1785
1786
1787
1788
# File 'lib/framework/dateOrig.rb', line 1785

def to_s # 4p
  format('%.4d-%02d-%02dT%02d:%02d:%02d%s',
  year, mon, mday, hour, min, sec, zone)
end

#to_timeObject



1851
1852
1853
1854
1855
1856
1857
# File 'lib/framework/dateOrig.rb', line 1851

def to_time
  d = new_offset(0)
  d.instance_eval do
    Time.utc(year(), mon(), mday(), hour(), min(), sec + sec_fraction)
  end.
	getlocal
end

#wdayObject



200
# File 'lib/framework/dateME.rb', line 200

def wday() @m_time.wday end

#xmlschema(n) ⇒ Object

:nodoc:



1311
# File 'lib/framework/date/format.rb', line 1311

def xmlschema(n=0) iso8601(n) end

#yearObject



202
# File 'lib/framework/dateME.rb', line 202

def year() @m_time.year end