Ruby Date Functions

EditRocket provides the following information on Date functions in the Ruby source code builder.

ajd() - Get the date as an Astronomical Julian Day Number.

ajd_to_amjd(ajd) - Convert an Astronomical Julian Day Number to an Astronomical Modified Julian Day Number.

ajd_to_jd(ajd, of=0) - Convert an Astronomical Julian Day Number to a (civil) Julian Day Number.

amjd() - Get the date as an Astronomical Modified Julian Day Number.

amjd_to_ajd(amjd) - Convert an Astronomical Modified Julian Day Number to an Astronomical Julian Day Number.

asctime() - alias_method :format, :strftime

civil(y=-4712, m=1, d=1, sg=ITALY) - Create a new Date object for the Civil Date specified by year y, month m, and day-of-month d.

civil_to_jd(y, m, d, sg=GREGORIAN) - Convert a Civil Date to a Julian Day Number. y, m, and d are the year, month, and day of the month. sg specifies the Day of Calendar Reform.

commercial(y=1582, w=41, d=5, sg=ITALY) - Create a new Date object for the Commercial Date specified by year y, week-of-year w, and day-of-week d.

commercial_to_jd(y, w, d, ns=GREGORIAN) - Convert a Commercial Date to a Julian Day Number.

ctime() - "Alias for #asctime"

cwday() - Get the commercial day of the week of this date. Monday is commercial day-of-week 1; Sunday is commercial day-of-week 7.

cweek() - Get the commercial week of the year of this date.

cwyear() - Get the commercial year of this date. See Commercial Date in the introduction for how this differs from the normal year.

day() - "Alias for #mday"

day_fraction() - Get any fractional day part of the date.

day_fraction_to_time(fr) - Convert a fractional day fr to [hours, minutes, seconds, fraction_of_a_second]

downto(min) - Step backward one day at a time until we reach min (inclusive), yielding each date as we go.

england() - Create a copy of this Date object that uses the English/Colonial Day of Calendar Reform.

eql?(other) - Is this Date equal to other?

gregorian?(jd, sg) - Does a given Julian Day Number fall inside the new-style (Gregorian) calendar?

gregorian?(jd, sg) - Does a given Julian Day Number fall inside the new-style (Gregorian) calendar?

gregorian() - Create a copy of this Date object that always uses the Gregorian Calendar.

gregorian_leap?(y) - Is a year a leap year in the Gregorian calendar?

hash() - Calculate a hash value for this date.

inspect() - Return internal object state as a programmer-readable string.

italy() - Create a copy of this Date object that uses the Italian/Catholic Day of Calendar Reform.

jd(jd=0, sg=ITALY) - Create a new Date object from a Julian Day Number.

jd(jd=0, sg=ITALY) - Create a new Date object from a Julian Day Number.

jd_to_ajd(jd, fr, of=0) - Convert a (civil) Julian Day Number to an Astronomical Julian Day Number.

jd_to_civil(jd, sg=GREGORIAN) - Convert a Julian Day Number to a Civil Date. jd is the Julian Day Number. sg specifies the Day of Calendar Reform.

jd_to_commercial(jd, sg=GREGORIAN) - Convert a Julian Day Number to a Commercial Date

jd_to_ld(jd) - Convert a Julian Day Number to the number of days since the adoption of the Gregorian Calendar (in Italy).

jd_to_mjd(jd) - Convert a Julian Day Number to a Modified Julian Day Number.

jd_to_ordinal(jd, sg=GREGORIAN) - Convert a Julian Day Number to an Ordinal Date.

jd_to_wday(jd) - Convert a Julian Day Number to the day of the week.

julian?(jd, sg) - Does a given Julian Day Number fall inside the old-style (Julian) calendar?

julian?(jd, sg) - Does a given Julian Day Number fall inside the old-style (Julian) calendar?

julian() - Create a copy of this Date object that always uses the Julian Calendar.

julian_leap?(y) - Is a year a leap year in the Julian calendar?

ld() - Get the date as the number of days since the Day of Calendar Reform (in Italy and the Catholic countries).

ld_to_jd(ld) - Convert a count of the number of days since the adoption of the Gregorian Calendar (in Italy) to a Julian Day Number.

leap?() - Is this a leap year?

mday() - Get the day-of-the-month of this date.

mjd() - Get the date as a Modified Julian Day Number.

mjd_to_jd(mjd) - Convert a Modified Julian Day Number to a Julian Day Number.

mon() - Get the month of this date.

month() - "Alias for #mon"

new(ajd=0, of=0, sg=ITALY) - "NOTE this is the documentation for the method new!(). If you are reading this as the documentation for new(), that is because rdoc doesn't fully support the aliasing of the initialize() method. new() is in fact an alias for #civil(): read the documentation for that method instead."

new_start(sg=self.class::ITALY) - Create a copy of this Date object using a new Day of Calendar Reform.

next() - Return a new Date one day after this one.

ordinal(y=-4712, d=1, sg=ITALY) - Create a new Date object from an Ordinal Date, specified by year y and day-of-year d. d can be negative, in which it counts backwards from the end of the year. No year wraparound is performed, however. An invalid value for d results in an ArgumentError being raised.

ordinal_to_jd(y, d, sg=GREGORIAN) - Convert an Ordinal Date to a Julian Day Number.

parse(str='-4712-01-01', comp=false, sg=ITALY) - Create a new Date object by parsing from a String, without specifying the format.

start() - When is the Day of Calendar Reform for this Date object?

step(limit, step=1) - Step the current date forward step days at a time (or backward, if step is negative) until we reach limit (inclusive), yielding the resultant date at each step.

strftime(fmt='%F') -

strptime(str='-4712-01-01', fmt='%F', sg=ITALY) - Create a new Date object by parsing from a String according to a specified format.

succ() - "Alias for #next"

time_to_day_fraction(h, min, s) - Convert an h hour, min minutes, s seconds period to a fractional day.

to_s() - Return the date as a human-readable string.

to_yaml( opts = {} ) -

today(sg=ITALY) - Create a new Date object representing today.

upto(max) - Step forward one day at a time until we reach max (inclusive), yielding each date as we go.

valid_civil?(y, m, d, sg=ITALY) - Do year y, month m, and day-of-month d make a valid Civil Date? Returns the corresponding Julian Day Number if they do, nil if they don't.

valid_commercial?(y, w, d, sg=ITALY) - Do year y, week-of-year w, and day-of-week d make a valid Commercial Date? Returns the corresponding Julian Day Number if they do, nil if they don't.

valid_jd?(jd, sg=ITALY) - Is jd a valid Julian Day Number?

valid_ordinal?(y, d, sg=ITALY) - Do the year y and day-of-year d make a valid Ordinal Date? Returns the corresponding Julian Day Number if they do, or nil if they don't.

valid_time?(h, min, s) - Do hour h, minute min, and second s constitute a valid time?

wday() - Get the week day of this date. Sunday is day-of-week 0; Saturday is day-of-week 6.

yday() - Get the day-of-the-year of this date.

year() - Get the year of this date.