Class: ThirdBase::Date

Inherits:
Object
  • Object
show all
Extended by:
CompatClassMethods, ClassMethods, DateCompatClassMethods
Includes:
Comparable, CompatInstanceMethods, InstanceMethods, DateCompatInstanceMethods
Defined in:
lib/third_base/date.rb,
lib/third_base/make_compat.rb

Overview

ThirdBase’s date class, a simple class which, unlike the standard Date class, does not include any time information.

This class is significantly faster than the standard Date class for two reasons. First, it does not depend on the Rational class (which is slow). Second, it doesn’t convert all dates to julian dates unless it is necessary.

Direct Known Subclasses

Date, DateTime

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

MONTHNAMES =
[nil] + %w(January February March April May June July August September October November December)
ABBR_MONTHNAMES =
[nil] + %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
MONTH_NUM_MAP =
{}
DAYNAMES =
%w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
ABBR_DAYNAMES =
%w(Sun Mon Tue Wed Thu Fri Sat)
DAY_NUM_MAP =
{}
CUMMULATIVE_MONTH_DAYS =
{1=>0, 2=>31, 3=>59, 4=>90, 5=>120, 6=>151, 7=>181, 8=>212, 9=>243, 10=>273, 11=>304, 12=>334}
LEAP_CUMMULATIVE_MONTH_DAYS =
{1=>0, 2=>31, 3=>60, 4=>91, 5=>121, 6=>152, 7=>182, 8=>213, 9=>244, 10=>274, 11=>305, 12=>335}
DAYS_IN_MONTH =
{1=>31, 2=>28, 3=>31, 4=>30, 5=>31, 6=>30, 7=>31, 8=>31, 9=>30, 10=>31, 11=>30, 12=>31}
LEAP_DAYS_IN_MONTH =
{1=>31, 2=>29, 3=>31, 4=>30, 5=>31, 6=>30, 7=>31, 8=>31, 9=>30, 10=>31, 11=>30, 12=>31}
MONTHNAME_RE_PATTERN =
"(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|may|june|july|august|september|october|november|december)"
FULL_MONTHNAME_RE_PATTERN =
"(january|february|march|april|may|june|july|august|september|october|november|december)"
ABBR_MONTHNAME_RE_PATTERN =
"(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)"
FULL_DAYNAME_RE_PATTERN =
"(sunday|monday|tuesday|wednesday|thursday|friday|saturday)"
ABBR_DAYNAME_RE_PATTERN =
"(sun|mon|tue|wed|thu|fri|sat)"
PARSER_LIST =
[]
DEFAULT_PARSER_LIST =
[:iso, :us, :num]
PARSERS =
{}
DEFAULT_PARSERS =
{}
STRFTIME_RE =
/%./o
STRPTIME_PROC_A =
proc{|h,x| h[:cwday] = DAY_NUM_MAP[x.downcase]}
STRPTIME_PROC_B =
proc{|h,x| h[:month] = MONTH_NUM_MAP[x.downcase]}
STRPTIME_PROC_C =
proc{|h,x| h[:year] ||= x.to_i*100}
STRPTIME_PROC_d =
proc{|h,x| h[:day] = x.to_i}
STRPTIME_PROC_G =
proc{|h,x| h[:cwyear] = x.to_i}
STRPTIME_PROC_g =
proc{|h,x| h[:cwyear] = two_digit_year(x)}
STRPTIME_PROC_j =
proc{|h,x| h[:yday] = x.to_i}
STRPTIME_PROC_m =
proc{|h,x| h[:month] = x.to_i}
STRPTIME_PROC_u =
proc{|h,x| h[:cwday] = x.to_i}
STRPTIME_PROC_V =
proc{|h,x| h[:cweek] = x.to_i}
STRPTIME_PROC_y =
proc{|h,x| h[:year] = two_digit_year(x)}
STRPTIME_PROC_Y =
proc{|h,x| h[:year] = x.to_i}
UNIXEPOCH =
2440588

Method Summary

Methods included from ClassMethods

add_parser, add_parser_type, civil, commercial, jd, new, ordinal, parse, reset_parsers!, strptime, today, use_parsers

Methods included from CompatClassMethods

_parse, ajd_to_amjd, ajd_to_jd, amjd_to_ajd, civil_to_jd, commercial_to_jd, day_fraction_to_time, gregorian?, jd_to_ajd, jd_to_civil, jd_to_commercial, jd_to_ld, jd_to_mjd, jd_to_ordinal, jd_to_wday, julian?, julian_leap?, ld_to_jd, leap?, mjd_to_jd, ordinal_to_jd, time_to_day_fraction, valid_civil?, valid_commercial?, valid_jd?, valid_ordinal?, valid_time?, zone_to_diff

Methods included from DateCompatClassMethods

_strptime, civil, commercial, jd, ordinal, parse, strptime, today

Methods included from DateCompatInstanceMethods

#asctime, #day_fraction

Methods included from CompatInstanceMethods

#ajd, #amjd, #gregorian, #gregorian?, #julian?, #ld, #mday, #new_start, #start

Methods included from InstanceMethods

#+, #-, #<<, #<=>, #==, #===, #>>, #cwday, #cweek, #cwyear, #day, #downto, #eql?, #hash, #initialize, #inspect, #jd, #leap?, #mon, #step, #strftime, #succ, #to_s, #upto, #wday, #yday, #year