Some terms and definitions are based on ISO 8601 and JIS X 0301.
The calendar date is a particular day of a calendar year, identified by its ordinal number within a calendar month within that year.
The ordinal date is a particular day of a calendar year identified by its ordinal number within the year.
The week date is a date identified by calendar week and day numbers.
The calendar week is a seven day period within a calendar year, starting on a Monday and identified by its ordinal number within the year; the first calendar week of the year is the one that includes the first Thursday of that year. In the Gregorian calendar, this is equivalent to the week which includes January 4.
The Julian day number is in elapsed days since noon (Greenwich mean time) on January 1, 4713 BCE (in the Julian calendar).
In this document, the astronomical Julian day number is same as the original Julian day number. And the chronological Julian day number is a variation of the Julian day number. Its days begin at midnight on local time.
In this document, when the term "Julian day number" simply appears, it just refers to "chronological Julian day number", not the original.
The modified Julian day number is in elapsed days since midnight (Coordinated universal time) on November 17, 1858 CE (in the Gregorian calendar).
In this document, the astronomical modified Julian day number is same as the original modified Julian day number. And the chronological modified Julian day number is a variation of the modified Julian day number. Its days begin at midnight on local time.
In this document, when the term "modified Julian day number" simply appears, it just refers to "chronological modified Julian day number", not the original.
Object
Comparable
Creates a date object denoting the given calendar date.
In this class, BCE years are counted astronomically. Thus, the year before the year 1 is the year zero, and the year preceding the year zero is the year -1. The month and the day of month should be a negative or a positive number (reverse order when negative). They should not be zero.
The last argument should be a Julian day number which denotes the first day of the Gregorian calendar. You can also give Date::GREGORIAN which mean the proleptic Gregorian calendar, and Date::JULIAN which mean the proleptic Julian calendar. Default is Date::ITALY (October 15, 1582).
See also jd.
Creates a date object denoting the given week date.
The week and the day of week should be a negative or a positive number (reverse order when negative). They should not be zero.
This method does not accept dates before the day of calendar reform.
See also jd and new.
Creates a date object denoting the given Julian day number.
In this class, some important methods do not accept negative Julian day numbers.
See also new.
Creates a date object denoting the given ordinal date.
The day of year should be a negative or a positive number (reverse order when negative). It should not be zero.
See also jd and new.
Parses the given representation of dates and times, and creates a date object.
If the optional second argument is true and the detected year is in the range "00" to "99", considers the year a 2-digit form and makes it full. Default is false.
_parse is also available. This method is similar to parse, but returns a hash which contain detected elements, not creates a date object.
Parses the given representation of dates and times with the given template, and creates a date object.
For example, the following formats are acceptable:
%Y-%m-%d %Y-%j %G-W%V-%u %s %Q
_strptime is also available. This method is similar to strptime, but returns a hash which contain detected elements, not creates a date object.
See also strptime(3) and strftime.
Returns true if the given calendar date is valid, and false if not.
See also jd and civil.
Returns true if the given week date is valid, and false if not.
See also jd and commercial.
Just returns true.
It's nonsense, but is for symmetry.
See also jd.
Returns true if the given ordinal date is valid, and false if not.
See also jd and ordinal.
step(min, -1){|date| ...}
.
new_start(Date::ENGLAND)
.
new_start(Date::GREGORIAN)
.
new_start(Date::ITALY)
.
Returns the Julian day number. It has no time of the day.
ajd is also available. This method is similar to jd, but returns the astronomical Julian day number. It may have time of the day.
new_start(Date::JULIAN)
.
Returns the modified Julian day number. It has no time of the day.
amjd is also available. This method is similar to mjd, but returns the astronomical modified Julian day number. It may have time of the day.
Duplicates self and resets the its first day of the Gregorian calendar. Default is Date::ITALY (October 15, 1582).
See also new.
Returns a Julian day number denoting the first day of the Gregorian calendar.
See also new.
Formats the date with the given template. The following conversion specifications are supported:
%A, %a, %B, %b, %C, %c, %D, %d, %e, %F, %G, %g, %H, %h, %I, %j, %k, %L, %l, %M, %m, %N, %n, %P, %p, %Q, %R, %r, %S, %s, %T, %t, %U, %u, %V, %v, %W, %w, %X, %x, %Y, %y, %Z, %z, %%, %+
See also strftime(3) and strptime.
step(max, 1){|date| ...}
.
Date
Duplicates self and resets the its offset. Default is zero (UTC).
See also new.
Parses the given representation of dates and times, and returns an array which contain detected elements (year, month, day of month, hour, minute, second, timezone and day of week).
If the optional second argument is true and the detected year is in the range 00 to 99, considers the year a 2-digit form and makes it full. Default is false.
parsedate can handle various formats. For example, the following representaions are acceptable:
Sat Saturday 1999-08-28 21:45:09 09:45:09 PM 1999-08-28T21:45:09+0900 19990828 214509 H11.08.28T21:45:09Z Sat Aug 28 21:45:09 1999 Sat Aug 28 21:45:09 JST 1999 Sat, 28 Aug 1999 21:45:09 -0400 Saturday, 28-Aug-99 21:45:09 GMT 08/28/1999 1999/08/28
See also Date::parse.