1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

date_core.c: [DOC] revise docs [ci skip]

* fix malformed rdoc for Date#today, Date._strptime,
  and DateTime._strptime
* add code examples for Date#<< and Date#>> to demonstrate
  that different dates can result in the same return value
* use Date::ITALY in call-seq instead of only ITALY
* fix some copy/paste mistakes where Date should be DateTime
* fix various errors and grammar
* fix cross references and formatting

[ruby-core:79433] [Bug #13193]
Author:    Marcus Stollsteimer <sto.mar@web.de>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-02-06 07:34:13 +00:00
parent 84012757a7
commit bcad5a51d7

View file

@ -2462,7 +2462,7 @@ date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
* *
* Date.valid_jd?(2451944) #=> true * Date.valid_jd?(2451944) #=> true
* *
* See also jd. * See also ::jd.
*/ */
static VALUE static VALUE
date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass) date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass)
@ -2551,7 +2551,7 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_date?(2001,2,3) #=> true * Date.valid_date?(2001,2,3) #=> true
* Date.valid_date?(2001,2,29) #=> false * Date.valid_date?(2001,2,29) #=> false
* *
* See also jd and civil. * See also ::jd and ::civil.
*/ */
static VALUE static VALUE
date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass) date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass)
@ -2632,7 +2632,7 @@ date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_ordinal?(2001,34) #=> true * Date.valid_ordinal?(2001,34) #=> true
* Date.valid_ordinal?(2001,366) #=> false * Date.valid_ordinal?(2001,366) #=> false
* *
* See also jd and ordinal. * See also ::jd and ::ordinal.
*/ */
static VALUE static VALUE
date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass) date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
@ -2714,7 +2714,7 @@ date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
* Date.valid_commercial?(2001,5,6) #=> true * Date.valid_commercial?(2001,5,6) #=> true
* Date.valid_commercial?(2001,5,8) #=> false * Date.valid_commercial?(2001,5,8) #=> false
* *
* See also jd and commercial. * See also ::jd and ::commercial.
*/ */
static VALUE static VALUE
date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass) date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
@ -3262,7 +3262,7 @@ static VALUE d_lite_plus(VALUE, VALUE);
* Date.jd(2451945) #=> #<Date: 2001-02-04 ...> * Date.jd(2451945) #=> #<Date: 2001-02-04 ...>
* Date.jd(0) #=> #<Date: -4712-01-01 ...> * Date.jd(0) #=> #<Date: -4712-01-01 ...>
* *
* See also new. * See also ::new.
*/ */
static VALUE static VALUE
date_s_jd(int argc, VALUE *argv, VALUE klass) date_s_jd(int argc, VALUE *argv, VALUE klass)
@ -3312,7 +3312,7 @@ date_s_jd(int argc, VALUE *argv, VALUE klass)
* Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...> * Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...>
* Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...> * Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
* *
* See also jd and new. * See also ::jd and ::new.
*/ */
static VALUE static VALUE
date_s_ordinal(int argc, VALUE *argv, VALUE klass) date_s_ordinal(int argc, VALUE *argv, VALUE klass)
@ -3380,7 +3380,7 @@ date_s_ordinal(int argc, VALUE *argv, VALUE klass)
* Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...> * Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
* Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...> * Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
* *
* See also jd. * See also ::jd.
*/ */
static VALUE static VALUE
date_s_civil(int argc, VALUE *argv, VALUE klass) date_s_civil(int argc, VALUE *argv, VALUE klass)
@ -3457,7 +3457,7 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
* Date.commercial(2002) #=> #<Date: 2001-12-31 ...> * Date.commercial(2002) #=> #<Date: 2001-12-31 ...>
* Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...> * Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...>
* *
* See also jd and new. * See also ::jd and ::new.
*/ */
static VALUE static VALUE
date_s_commercial(int argc, VALUE *argv, VALUE klass) date_s_commercial(int argc, VALUE *argv, VALUE klass)
@ -3631,9 +3631,9 @@ static void set_sg(union DateData *, double);
* call-seq: * call-seq:
* Date.today([start=Date::ITALY]) -> date * Date.today([start=Date::ITALY]) -> date
* *
* Date.today #=> #<Date: 2011-06-11 ..>
*
* Creates a date object denoting the present day. * Creates a date object denoting the present day.
*
* Date.today #=> #<Date: 2011-06-11 ...>
*/ */
static VALUE static VALUE
date_s_today(int argc, VALUE *argv, VALUE klass) date_s_today(int argc, VALUE *argv, VALUE klass)
@ -4236,7 +4236,7 @@ date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
* Date._strptime('2001-02-03', '%Y-%m-%d') * Date._strptime('2001-02-03', '%Y-%m-%d')
* #=> {:year=>2001, :mon=>2, :mday=>3} * #=> {:year=>2001, :mon=>2, :mday=>3}
* *
* See also strptime(3) and strftime. * See also strptime(3) and #strftime.
*/ */
static VALUE static VALUE
date_s__strptime(int argc, VALUE *argv, VALUE klass) date_s__strptime(int argc, VALUE *argv, VALUE klass)
@ -4246,7 +4246,7 @@ date_s__strptime(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* Date.strptime([string='-4712-01-01'[, format='%F'[, start=ITALY]]]) -> date * Date.strptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]) -> date
* *
* Parses the given representation of date and time with the given * Parses the given representation of date and time with the given
* template, and creates a date object. strptime does not support * template, and creates a date object. strptime does not support
@ -4260,7 +4260,7 @@ date_s__strptime(int argc, VALUE *argv, VALUE klass)
* Date.strptime('2001 05 6', '%Y %W %u') #=> #<Date: 2001-02-03 ...> * Date.strptime('2001 05 6', '%Y %W %u') #=> #<Date: 2001-02-03 ...>
* Date.strptime('sat3feb01', '%a%d%b%y') #=> #<Date: 2001-02-03 ...> * Date.strptime('sat3feb01', '%a%d%b%y') #=> #<Date: 2001-02-03 ...>
* *
* See also strptime(3) and strftime. * See also strptime(3) and #strftime.
*/ */
static VALUE static VALUE
date_s_strptime(int argc, VALUE *argv, VALUE klass) date_s_strptime(int argc, VALUE *argv, VALUE klass)
@ -4340,7 +4340,7 @@ date_s__parse(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* Date.parse(string='-4712-01-01'[, comp=true[, start=ITALY]]) -> date * Date.parse(string='-4712-01-01'[, comp=true[, start=Date::ITALY]]) -> date
* *
* Parses the given representation of date and time, and creates a * Parses the given representation of date and time, and creates a
* date object. This method does not function as a validator. * date object. This method does not function as a validator.
@ -4400,7 +4400,7 @@ date_s__iso8601(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.iso8601(string='-4712-01-01'[, start=ITALY]) -> date * Date.iso8601(string='-4712-01-01'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some typical ISO 8601 formats. * some typical ISO 8601 formats.
@ -4443,7 +4443,7 @@ date_s__rfc3339(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> date * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some typical RFC 3339 formats. * some typical RFC 3339 formats.
@ -4484,7 +4484,7 @@ date_s__xmlschema(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.xmlschema(string='-4712-01-01'[, start=ITALY]) -> date * Date.xmlschema(string='-4712-01-01'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some typical XML Schema formats. * some typical XML Schema formats.
@ -4526,8 +4526,8 @@ date_s__rfc2822(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> date * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
* Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> date * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some typical RFC 2822 formats. * some typical RFC 2822 formats.
@ -4569,7 +4569,7 @@ date_s__httpdate(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=ITALY]) -> date * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some RFC 2616 format. * some RFC 2616 format.
@ -4611,7 +4611,7 @@ date_s__jisx0301(VALUE klass, VALUE str)
/* /*
* call-seq: * call-seq:
* Date.jisx0301(string='-4712-01-01'[, start=ITALY]) -> date * Date.jisx0301(string='-4712-01-01'[, start=Date::ITALY]) -> date
* *
* Creates a new Date object by parsing from a string according to * Creates a new Date object by parsing from a string according to
* some typical JIS X 0301 formats. * some typical JIS X 0301 formats.
@ -5380,7 +5380,7 @@ dup_obj_with_new_start(VALUE obj, double sg)
* call-seq: * call-seq:
* d.new_start([start=Date::ITALY]) -> date * d.new_start([start=Date::ITALY]) -> date
* *
* Duplicates self and resets its the day of calendar reform. * Duplicates self and resets its day of calendar reform.
* *
* d = Date.new(1582,10,15) * d = Date.new(1582,10,15)
* d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...> * d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
@ -5498,9 +5498,9 @@ d_lite_new_offset(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* d + other -> date * d + other -> date
* *
* Returns a date object pointing other days after self. The other * Returns a date object pointing +other+ days after self. The other
* should be a numeric value. If the other is flonum, assumes its * should be a numeric value. If the other is a fractional number,
* precision is at most nanosecond. * assumes its precision is at most nanosecond.
* *
* Date.new(2001,2,3) + 1 #=> #<Date: 2001-02-04 ...> * Date.new(2001,2,3) + 1 #=> #<Date: 2001-02-04 ...>
* DateTime.new(2001,2,3) + Rational(1,2) * DateTime.new(2001,2,3) + Rational(1,2)
@ -5883,8 +5883,8 @@ minus_dd(VALUE self, VALUE other)
* *
* Returns the difference between the two dates if the other is a date * Returns the difference between the two dates if the other is a date
* object. If the other is a numeric value, returns a date object * object. If the other is a numeric value, returns a date object
* pointing other days before self. If the other is flonum, assumes * pointing +other+ days before self. If the other is a fractional number,
* its precision is at most nanosecond. * assumes its precision is at most nanosecond.
* *
* Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...> * Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
* DateTime.new(2001,2,3) - Rational(1,2) * DateTime.new(2001,2,3) - Rational(1,2)
@ -5965,12 +5965,13 @@ d_lite_next(VALUE self)
* call-seq: * call-seq:
* d >> n -> date * d >> n -> date
* *
* Returns a date object pointing n months after self. The n should * Returns a date object pointing +n+ months after self.
* be a numeric value. * The argument +n+ should be a numeric value.
* *
* Date.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...> * Date.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...>
* Date.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...> * Date.new(2001,1,30) >> 1 #=> #<Date: 2001-02-28 ...>
* Date.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...> * Date.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...>
* Date.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...>
*/ */
static VALUE static VALUE
d_lite_rshift(VALUE self, VALUE other) d_lite_rshift(VALUE self, VALUE other)
@ -6015,12 +6016,13 @@ d_lite_rshift(VALUE self, VALUE other)
* call-seq: * call-seq:
* d << n -> date * d << n -> date
* *
* Returns a date object pointing n months before self. The n should * Returns a date object pointing +n+ months before self.
* be a numeric value. * The argument +n+ should be a numeric value.
* *
* Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...> * Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
* Date.new(2001,1,31) << 11 #=> #<Date: 2000-02-29 ...> * Date.new(2001,1,30) << 11 #=> #<Date: 2000-02-29 ...>
* Date.new(2001,2,3) << -1 #=> #<Date: 2001-03-03 ...> * Date.new(2001,1,31) << 11 #=> #<Date: 2000-02-29 ...>
* Date.new(2001,2,3) << -1 #=> #<Date: 2001-03-03 ...>
*/ */
static VALUE static VALUE
d_lite_lshift(VALUE self, VALUE other) d_lite_lshift(VALUE self, VALUE other)
@ -6033,7 +6035,7 @@ d_lite_lshift(VALUE self, VALUE other)
* call-seq: * call-seq:
* d.next_month([n=1]) -> date * d.next_month([n=1]) -> date
* *
* This method is equivalent to d >> n * This method is equivalent to d >> n.
*/ */
static VALUE static VALUE
d_lite_next_month(int argc, VALUE *argv, VALUE self) d_lite_next_month(int argc, VALUE *argv, VALUE self)
@ -6050,7 +6052,7 @@ d_lite_next_month(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* d.prev_month([n=1]) -> date * d.prev_month([n=1]) -> date
* *
* This method is equivalent to d << n * This method is equivalent to d << n.
*/ */
static VALUE static VALUE
d_lite_prev_month(int argc, VALUE *argv, VALUE self) d_lite_prev_month(int argc, VALUE *argv, VALUE self)
@ -6067,7 +6069,7 @@ d_lite_prev_month(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* d.next_year([n=1]) -> date * d.next_year([n=1]) -> date
* *
* This method is equivalent to d >> (n * 12) * This method is equivalent to d >> (n * 12).
*/ */
static VALUE static VALUE
d_lite_next_year(int argc, VALUE *argv, VALUE self) d_lite_next_year(int argc, VALUE *argv, VALUE self)
@ -6084,7 +6086,7 @@ d_lite_next_year(int argc, VALUE *argv, VALUE self)
* call-seq: * call-seq:
* d.prev_year([n=1]) -> date * d.prev_year([n=1]) -> date
* *
* This method is equivalent to d << (n * 12) * This method is equivalent to d << (n * 12).
*/ */
static VALUE static VALUE
d_lite_prev_year(int argc, VALUE *argv, VALUE self) d_lite_prev_year(int argc, VALUE *argv, VALUE self)
@ -6272,11 +6274,11 @@ cmp_dd(VALUE self, VALUE other)
* should be a date object or a numeric value as an astronomical * should be a date object or a numeric value as an astronomical
* Julian day number. * Julian day number.
* *
* Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1 * Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1
* Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0 * Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0
* Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1 * Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1
* Date.new(2001,2,3) <=> Object.new #=> nil * Date.new(2001,2,3) <=> Object.new #=> nil
* Date.new(2001,2,3) <=> Rational(4903887,2)#=> 0 * Date.new(2001,2,3) <=> Rational(4903887,2) #=> 0
* *
* See also Comparable. * See also Comparable.
*/ */
@ -6416,8 +6418,8 @@ static VALUE strftimev(const char *, VALUE,
* call-seq: * call-seq:
* d.to_s -> string * d.to_s -> string
* *
* Returns a string in an ISO 8601 format (This method doesn't use the * Returns a string in an ISO 8601 format. (This method doesn't use the
* expanded representations). * expanded representations.)
* *
* Date.new(2001,2,3).to_s #=> "2001-02-03" * Date.new(2001,2,3).to_s #=> "2001-02-03"
*/ */
@ -6691,7 +6693,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
* *
* Formats date according to the directives in the given format * Formats date according to the directives in the given format
* string. * string.
* The directives begins with a percent (%) character. * The directives begin with a percent (%) character.
* Any text not listed as a directive will be passed through to the * Any text not listed as a directive will be passed through to the
* output string. * output string.
* *
@ -6807,11 +6809,12 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
* %T - 24-hour time (%H:%M:%S) * %T - 24-hour time (%H:%M:%S)
* %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) * %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
* *
* This method is similar to strftime() function defined in ISO C and POSIX. * This method is similar to the strftime() function defined in ISO C
* and POSIX.
* Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) * Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
* are locale dependent in the function. * are locale dependent in the function.
* However this method is locale independent. * However, this method is locale independent.
* So, the result may differ even if a same format string is used in other * So, the result may differ even if the same format string is used in other
* systems such as C. * systems such as C.
* It is good practice to avoid %x and %X because there are corresponding * It is good practice to avoid %x and %X because there are corresponding
* locale independent representations, %D and %T. * locale independent representations, %D and %T.
@ -6859,7 +6862,7 @@ date_strftime_internal(int argc, VALUE *argv, VALUE self,
* %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) * %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
* %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) * %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
* *
* See also strftime(3) and strptime. * See also strftime(3) and ::strptime.
*/ */
static VALUE static VALUE
d_lite_strftime(int argc, VALUE *argv, VALUE self) d_lite_strftime(int argc, VALUE *argv, VALUE self)
@ -7161,7 +7164,7 @@ date_s__load(VALUE klass, VALUE s)
* call-seq: * call-seq:
* DateTime.jd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]) -> datetime * DateTime.jd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]) -> datetime
* *
* Creates a datetime object denoting the given chronological Julian * Creates a DateTime object denoting the given chronological Julian
* day number. * day number.
* *
* DateTime.jd(2451944) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...> * DateTime.jd(2451944) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
@ -7229,7 +7232,7 @@ datetime_s_jd(int argc, VALUE *argv, VALUE klass)
* call-seq: * call-seq:
* DateTime.ordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]) -> datetime * DateTime.ordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]) -> datetime
* *
* Creates a date-time object denoting the given ordinal date. * Creates a DateTime object denoting the given ordinal date.
* *
* DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...> * DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
* DateTime.ordinal(2001,34,4,5,6,'+7') * DateTime.ordinal(2001,34,4,5,6,'+7')
@ -7305,7 +7308,7 @@ datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
* DateTime.civil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime * DateTime.civil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
* DateTime.new([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime * DateTime.new([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
* *
* Creates a date-time object denoting the given calendar date. * Creates a DateTime object denoting the given calendar date.
* *
* DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...> * DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
* DateTime.new(2001,2,3,4,5,6,'+7') * DateTime.new(2001,2,3,4,5,6,'+7')
@ -7403,7 +7406,7 @@ datetime_s_civil(int argc, VALUE *argv, VALUE klass)
* call-seq: * call-seq:
* DateTime.commercial([cwyear=-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime * DateTime.commercial([cwyear=-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
* *
* Creates a date-time object denoting the given week date. * Creates a DateTime object denoting the given week date.
* *
* DateTime.commercial(2001) #=> #<DateTime: 2001-01-01T00:00:00+00:00 ...> * DateTime.commercial(2001) #=> #<DateTime: 2001-01-01T00:00:00+00:00 ...>
* DateTime.commercial(2002) #=> #<DateTime: 2001-12-31T00:00:00+00:00 ...> * DateTime.commercial(2002) #=> #<DateTime: 2001-12-31T00:00:00+00:00 ...>
@ -7620,7 +7623,7 @@ datetime_s_nth_kday(int argc, VALUE *argv, VALUE klass)
* call-seq: * call-seq:
* DateTime.now([start=Date::ITALY]) -> datetime * DateTime.now([start=Date::ITALY]) -> datetime
* *
* Creates a date-time object denoting the present time. * Creates a DateTime object denoting the present time.
* *
* DateTime.now #=> #<DateTime: 2011-06-11T21:20:44+09:00 ...> * DateTime.now #=> #<DateTime: 2011-06-11T21:20:44+09:00 ...>
*/ */
@ -7823,7 +7826,7 @@ dt_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
* template, and returns a hash of parsed elements. _strptime does * template, and returns a hash of parsed elements. _strptime does
* not support specification of flags and width unlike strftime. * not support specification of flags and width unlike strftime.
* *
* See also strptime(3) and strftime. * See also strptime(3) and #strftime.
*/ */
static VALUE static VALUE
datetime_s__strptime(int argc, VALUE *argv, VALUE klass) datetime_s__strptime(int argc, VALUE *argv, VALUE klass)
@ -7833,10 +7836,10 @@ datetime_s__strptime(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=ITALY]]]) -> datetime * DateTime.strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=Date::ITALY]]]) -> datetime
* *
* Parses the given representation of date and time with the given * Parses the given representation of date and time with the given
* template, and creates a date object. strptime does not support * template, and creates a DateTime object. strptime does not support
* specification of flags and width unlike strftime. * specification of flags and width unlike strftime.
* *
* DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z') * DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z')
@ -7856,7 +7859,7 @@ datetime_s__strptime(int argc, VALUE *argv, VALUE klass)
* DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z') * DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z')
* #=> #<DateTime: 2001-02-03T16:00:00+07:00 ...> * #=> #<DateTime: 2001-02-03T16:00:00+07:00 ...>
* *
* See also strptime(3) and strftime. * See also strptime(3) and #strftime.
*/ */
static VALUE static VALUE
datetime_s_strptime(int argc, VALUE *argv, VALUE klass) datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
@ -7886,10 +7889,10 @@ datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=ITALY]]) -> datetime * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=Date::ITALY]]) -> datetime
* *
* Parses the given representation of date and time, and creates a * Parses the given representation of date and time, and creates a
* date object. This method does not function as a validator. * DateTime object. This method does not function as a validator.
* *
* If the optional second argument is true and the detected year is in * If the optional second argument is true and the detected year is in
* the range "00" to "99", makes it full. * the range "00" to "99", makes it full.
@ -7929,9 +7932,9 @@ datetime_s_parse(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some typical ISO 8601 formats. * some typical ISO 8601 formats.
* *
* DateTime.iso8601('2001-02-03T04:05:06+07:00') * DateTime.iso8601('2001-02-03T04:05:06+07:00')
@ -7963,9 +7966,9 @@ datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some typical RFC 3339 formats. * some typical RFC 3339 formats.
* *
* DateTime.rfc3339('2001-02-03T04:05:06+07:00') * DateTime.rfc3339('2001-02-03T04:05:06+07:00')
@ -7993,9 +7996,9 @@ datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some typical XML Schema formats. * some typical XML Schema formats.
* *
* DateTime.xmlschema('2001-02-03T04:05:06+07:00') * DateTime.xmlschema('2001-02-03T04:05:06+07:00')
@ -8023,10 +8026,10 @@ datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> datetime * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
* DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> datetime * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some typical RFC 2822 formats. * some typical RFC 2822 formats.
* *
* DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700') * DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
@ -8054,9 +8057,9 @@ datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=ITALY]) -> datetime * DateTime.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some RFC 2616 format. * some RFC 2616 format.
* *
* DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT') * DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
@ -8084,9 +8087,9 @@ datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
/* /*
* call-seq: * call-seq:
* DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) -> datetime
* *
* Creates a new Date object by parsing from a string according to * Creates a new DateTime object by parsing from a string according to
* some typical JIS X 0301 formats. * some typical JIS X 0301 formats.
* *
* DateTime.jisx0301('H13.02.03T04:05:06+07:00') * DateTime.jisx0301('H13.02.03T04:05:06+07:00')
@ -8116,8 +8119,8 @@ datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
* call-seq: * call-seq:
* dt.to_s -> string * dt.to_s -> string
* *
* Returns a string in an ISO 8601 format (This method doesn't use the * Returns a string in an ISO 8601 format. (This method doesn't use the
* expanded representations). * expanded representations.)
* *
* DateTime.new(2001,2,3,4,5,6,'-7').to_s * DateTime.new(2001,2,3,4,5,6,'-7').to_s
* #=> "2001-02-03T04:05:06-07:00" * #=> "2001-02-03T04:05:06-07:00"
@ -8134,7 +8137,7 @@ dt_lite_to_s(VALUE self)
* *
* Formats date according to the directives in the given format * Formats date according to the directives in the given format
* string. * string.
* The directives begins with a percent (%) character. * The directives begin with a percent (%) character.
* Any text not listed as a directive will be passed through to the * Any text not listed as a directive will be passed through to the
* output string. * output string.
* *
@ -8155,7 +8158,7 @@ dt_lite_to_s(VALUE self)
* *
* The minimum field width specifies the minimum width. * The minimum field width specifies the minimum width.
* *
* The modifier is "E" and "O". * The modifiers are "E" and "O".
* They are ignored. * They are ignored.
* *
* Format directives: * Format directives:
@ -8251,11 +8254,12 @@ dt_lite_to_s(VALUE self)
* %T - 24-hour time (%H:%M:%S) * %T - 24-hour time (%H:%M:%S)
* %+ - date(1) (%a %b %e %H:%M:%S %Z %Y) * %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
* *
* This method is similar to strftime() function defined in ISO C and POSIX. * This method is similar to the strftime() function defined in ISO C
* and POSIX.
* Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z) * Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
* are locale dependent in the function. * are locale dependent in the function.
* However this method is locale independent. * However, this method is locale independent.
* So, the result may differ even if a same format string is used in other * So, the result may differ even if the same format string is used in other
* systems such as C. * systems such as C.
* It is good practice to avoid %x and %X because there are corresponding * It is good practice to avoid %x and %X because there are corresponding
* locale independent representations, %D and %T. * locale independent representations, %D and %T.
@ -8303,7 +8307,7 @@ dt_lite_to_s(VALUE self)
* %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic) * %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
* %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended) * %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
* *
* See also strftime(3) and strptime. * See also strftime(3) and ::strptime.
*/ */
static VALUE static VALUE
dt_lite_strftime(int argc, VALUE *argv, VALUE self) dt_lite_strftime(int argc, VALUE *argv, VALUE self)
@ -8334,7 +8338,7 @@ iso8601_timediv(VALUE self, long n)
* dt.xmlschema([n=0]) -> string * dt.xmlschema([n=0]) -> string
* *
* This method is equivalent to strftime('%FT%T'). The optional * This method is equivalent to strftime('%FT%T'). The optional
* argument n is length of fractional seconds. * argument +n+ is the number of digits for fractional seconds.
* *
* DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9) * DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9)
* #=> "2001-02-03T04:05:06.123456789+07:00" * #=> "2001-02-03T04:05:06.123456789+07:00"
@ -9003,13 +9007,13 @@ Init_date_core(void)
/* /*
* date and datetime class - Tadayoshi Funaba 1998-2011 * date and datetime class - Tadayoshi Funaba 1998-2011
* *
* 'date' provides two classes Date and DateTime. * 'date' provides two classes: Date and DateTime.
* *
* == Terms and definitions * == Terms and Definitions
* *
* Some terms and definitions are based on ISO 8601 and JIS X 0301. * Some terms and definitions are based on ISO 8601 and JIS X 0301.
* *
* === calendar date * === Calendar Date
* *
* The calendar date is a particular day of a calendar year, * The calendar date is a particular day of a calendar year,
* identified by its ordinal number within a calendar month within * identified by its ordinal number within a calendar month within
@ -9017,14 +9021,14 @@ Init_date_core(void)
* *
* In those classes, this is so-called "civil". * In those classes, this is so-called "civil".
* *
* === ordinal date * === Ordinal Date
* *
* The ordinal date is a particular day of a calendar year identified * The ordinal date is a particular day of a calendar year identified
* by its ordinal number within the year. * by its ordinal number within the year.
* *
* In those classes, this is so-called "ordinal". * In those classes, this is so-called "ordinal".
* *
* === week date * === Week Date
* *
* The week date is a date identified by calendar week and day numbers. * The week date is a date identified by calendar week and day numbers.
* *
@ -9034,15 +9038,15 @@ Init_date_core(void)
* includes the first Thursday of that year. In the Gregorian * includes the first Thursday of that year. In the Gregorian
* calendar, this is equivalent to the week which includes January 4. * calendar, this is equivalent to the week which includes January 4.
* *
* In those classes, this so-called "commercial". * In those classes, this is so-called "commercial".
* *
* === julian day number * === Julian Day Number
* *
* The Julian day number is in elapsed days since noon (Greenwich mean * The Julian day number is in elapsed days since noon (Greenwich Mean
* time) on January 1, 4713 BCE (in the Julian calendar). * Time) on January 1, 4713 BCE (in the Julian calendar).
* *
* In this document, the astronomical Julian day number is same as the * In this document, the astronomical Julian day number is the same as
* original Julian day number. And the chronological Julian day * the original Julian day number. And the chronological Julian day
* number is a variation of the Julian day number. Its days begin at * number is a variation of the Julian day number. Its days begin at
* midnight on local time. * midnight on local time.
* *
@ -9052,14 +9056,14 @@ Init_date_core(void)
* *
* In those classes, those are so-called "ajd" and "jd". * In those classes, those are so-called "ajd" and "jd".
* *
* === modified julian day number * === Modified Julian Day Number
* *
* The modified Julian day number is in elapsed days since midnight * The modified Julian day number is in elapsed days since midnight
* (Coordinated universal time) on November 17, 1858 CE (in the * (Coordinated Universal Time) on November 17, 1858 CE (in the
* Gregorian calendar). * Gregorian calendar).
* *
* In this document, the astronomical modified Julian day number is * In this document, the astronomical modified Julian day number is
* same as the original modified Julian day number. And the * the same as the original modified Julian day number. And the
* chronological modified Julian day number is a variation of the * chronological modified Julian day number is a variation of the
* modified Julian day number. Its days begin at midnight on local * modified Julian day number. Its days begin at midnight on local
* time. * time.
@ -9068,16 +9072,16 @@ Init_date_core(void)
* appears, it just refers to "chronological modified Julian day * appears, it just refers to "chronological modified Julian day
* number", not the original. * number", not the original.
* *
* In those classes, this is so-called "mjd". * In those classes, those are so-called "amjd" and "mjd".
* *
* == Date * == Date
* *
* A subclass of Object that includes Comparable module and easily handles * A subclass of Object that includes the Comparable module and
* date. * easily handles date.
* *
* Date object is created with Date::new, Date::jd, Date::ordinal, * A Date object is created with Date::new, Date::jd, Date::ordinal,
* Date::commercial, Date::parse, Date::strptime, Date::today, * Date::commercial, Date::parse, Date::strptime, Date::today,
* Time#to_date or etc. * Time#to_date, etc.
* *
* require 'date' * require 'date'
* *
@ -9098,7 +9102,7 @@ Init_date_core(void)
* *
* All date objects are immutable; hence cannot modify themselves. * All date objects are immutable; hence cannot modify themselves.
* *
* The concept of this date object can be represented as a tuple * The concept of a date object can be represented as a tuple
* of the day count, the offset and the day of calendar reform. * of the day count, the offset and the day of calendar reform.
* *
* The day count denotes the absolute position of a temporal * The day count denotes the absolute position of a temporal
@ -9113,10 +9117,11 @@ Init_date_core(void)
* The offset in this class is usually zero, and cannot be * The offset in this class is usually zero, and cannot be
* specified directly. * specified directly.
* *
* An optional argument the day of calendar reform (start) as a * A Date object can be created with an optional argument,
* Julian day number, which should be 2298874 to 2426355 or -/+oo. * the day of calendar reform as a Julian day number, which
* The default value is Date::ITALY (2299161=1582-10-15). See * should be 2298874 to 2426355 or negative/positive infinity.
* also sample/cal.rb. * The default value is +Date::ITALY+ (2299161=1582-10-15).
* See also sample/cal.rb.
* *
* $ ruby sample/cal.rb -c it 10 1582 * $ ruby sample/cal.rb -c it 10 1582
* October 1582 * October 1582
@ -9133,7 +9138,7 @@ Init_date_core(void)
* 17 18 19 20 21 22 23 * 17 18 19 20 21 22 23
* 24 25 26 27 28 29 30 * 24 25 26 27 28 29 30
* *
* Date object has various methods. See each reference. * A Date object has various methods. See each reference.
* *
* d = Date.parse('3rd Feb 2001') * d = Date.parse('3rd Feb 2001')
* #=> #<Date: 2001-02-03 ...> * #=> #<Date: 2001-02-03 ...>
@ -9181,12 +9186,12 @@ Init_date_core(void)
rb_define_const(cDate, "ENGLAND", INT2FIX(ENGLAND)); rb_define_const(cDate, "ENGLAND", INT2FIX(ENGLAND));
/* The Julian day number of the day of calendar reform for the /* The Julian day number of the day of calendar reform for the
* proleptic Julian calendar * proleptic Julian calendar.
*/ */
rb_define_const(cDate, "JULIAN", DBL2NUM(JULIAN)); rb_define_const(cDate, "JULIAN", DBL2NUM(JULIAN));
/* The Julian day number of the day of calendar reform for the /* The Julian day number of the day of calendar reform for the
* proleptic Gregorian calendar * proleptic Gregorian calendar.
*/ */
rb_define_const(cDate, "GREGORIAN", DBL2NUM(GREGORIAN)); rb_define_const(cDate, "GREGORIAN", DBL2NUM(GREGORIAN));
@ -9394,48 +9399,49 @@ Init_date_core(void)
/* /*
* == DateTime * == DateTime
* *
* A subclass of Date that easily handles date, hour, minute, second and * A subclass of Date that easily handles date, hour, minute, second,
* offset. * and offset.
* *
* DateTime does not consider any leap seconds, does not track * DateTime does not consider any leap seconds, does not track
* any summer time rules. * any summer time rules.
* *
* DateTime object is created with DateTime::new, DateTime::jd, * A DateTime object is created with DateTime::new, DateTime::jd,
* DateTime::ordinal, DateTime::commercial, DateTime::parse, * DateTime::ordinal, DateTime::commercial, DateTime::parse,
* DateTime::strptime, DateTime::now, Time#to_datetime or etc. * DateTime::strptime, DateTime::now, Time#to_datetime, etc.
* *
* require 'date' * require 'date'
* *
* DateTime.new(2001,2,3,4,5,6) * DateTime.new(2001,2,3,4,5,6)
* #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...> * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
* *
* The last element of day, hour, minute or second can be * The last element of day, hour, minute, or second can be a
* fractional number. The fractional number's precision is assumed * fractional number. The fractional number's precision is assumed
* at most nanosecond. * at most nanosecond.
* *
* DateTime.new(2001,2,3.5) * DateTime.new(2001,2,3.5)
* #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...> * #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
* *
* An optional argument the offset indicates the difference * An optional argument, the offset, indicates the difference
* between the local time and UTC. For example, <tt>Rational(3,24)</tt> * between the local time and UTC. For example, <tt>Rational(3,24)</tt>
* represents ahead of 3 hours of UTC, <tt>Rational(-5,24)</tt> represents * represents ahead of 3 hours of UTC, <tt>Rational(-5,24)</tt> represents
* behind of 5 hours of UTC. The offset should be -1 to +1, and * behind of 5 hours of UTC. The offset should be -1 to +1, and
* its precision is assumed at most second. The default value is * its precision is assumed at most second. The default value is
* zero(equals to UTC). * zero (equals to UTC).
* *
* DateTime.new(2001,2,3,4,5,6,Rational(3,24)) * DateTime.new(2001,2,3,4,5,6,Rational(3,24))
* #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...> * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
* *
* also accepts string form. * The offset also accepts string form:
* *
* DateTime.new(2001,2,3,4,5,6,'+03:00') * DateTime.new(2001,2,3,4,5,6,'+03:00')
* #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...> * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
* *
* An optional argument the day of calendar reform (start) denotes * An optional argument, the day of calendar reform (+start+), denotes
* a Julian day number, which should be 2298874 to 2426355 or * a Julian day number, which should be 2298874 to 2426355 or
* -/+oo. The default value is +Date::ITALY+ (2299161=1582-10-15). * negative/positive infinity.
* The default value is +Date::ITALY+ (2299161=1582-10-15).
* *
* DateTime object has various methods. See each reference. * A DateTime object has various methods. See each reference.
* *
* d = DateTime.parse('3rd Feb 2001 04:05:06+03:30') * d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')
* #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...> * #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>
@ -9462,22 +9468,22 @@ Init_date_core(void)
* died on the same day in history - * died on the same day in history -
* so much so that UNESCO named April 23 as * so much so that UNESCO named April 23 as
* {World Book Day because of this fact}[http://en.wikipedia.org/wiki/World_Book_Day]. * {World Book Day because of this fact}[http://en.wikipedia.org/wiki/World_Book_Day].
* However because England hadn't yet adopted * However, because England hadn't yet adopted the
* {Gregorian Calendar Reform}[http://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform] * {Gregorian Calendar Reform}[http://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform]
* (and wouldn't until {1752}[http://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750]) * (and wouldn't until {1752}[http://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750])
* their deaths are actually 10 days apart. * their deaths are actually 10 days apart.
* Since Ruby's Time class implements a * Since Ruby's Time class implements a
* {proleptic Gregorian calendar}[http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar] * {proleptic Gregorian calendar}[http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar]
* and has no concept of calendar reform then there's no way * and has no concept of calendar reform there's no way
* to express this. This is where DateTime steps in: * to express this with Time objects. This is where DateTime steps in:
* *
* shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND) * shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
* #=> Tue, 23 Apr 1616 00:00:00 +0000 * #=> Tue, 23 Apr 1616 00:00:00 +0000
* cervantes = DateTime.iso8601('1616-04-23', Date::ITALY) * cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
* #=> Sat, 23 Apr 1616 00:00:00 +0000 * #=> Sat, 23 Apr 1616 00:00:00 +0000
* *
* Already you can see something's weird - the days of the week * Already you can see something is weird - the days of the week
* are different, taking this further: * are different. Taking this further:
* *
* cervantes == shakespeare * cervantes == shakespeare
* #=> false * #=> false