Template:JULIANDAY/doc

This template computes the number of the Julian day starting at noon on the date given in parameter (in the Gregorian calendar, without any Julian correction for proleptic Gregorian dates where the calendar was not effectively applied).

The result is valid for all proleptic Gregorian calendar dates starting on March 1, 4800 BC (−4799) at midnight.

Syntax

 * year [month] [day] [hour] [minute] [second]


 * The year (required) must be astronomical (year=1 in 1 AD (Anno Domini), year=0 in 1 BC, year=-1 in 2 BC).
 * The month (optional, default value 1) is expressed between 1 and 12 from January to December (but offsets are possible for computing other years).
 * The year and month are first converted into a number of months, then rounded to the nearest integer to compute the actual year and month used for computing dates.
 * The day (optional, default value 1) is normally between 1 and 31 (but offsets are possible for computing other months). Decimals are possible for fractions of day.
 * The hour (optional, default value 12) is normally between 0 and 23 (but offsets are possible for computing other days). Note that Julian days begin at noon (hour = 12) and thus hours 0–11 of a solar day are one Julian day earlier than hours 12–23. The value may extend outside of the normal range and is considered as additional number of julian days (a Julian day is 24 hours or 86400 seconds exactly, ignoring any adjustment of leap seconds within the UTC calendar). Decimals are possible for fractions of hour.
 * The minute and second (optional, default value 0) are normally between 0 and 59 (but offsets are possible for computing other hours). Decimals are possible for fractions of minute or second.
 * All parameters can be any valid numeric expression which is evaluated before computing.

Note

 * The julian day, when computed modulo 7, grows from 0 (on Monday at noon) to 6 (on Sunday at noon)) and falls back to 0 (on next Monday). This corresponds to the order of days in the ISO week.

Limitations
Before March 4800 BC, the results may be offseted (by up to 365 or 366 days) due to the limitation of the MediaWiki  operators used in the implementation.

This limitation could be fixed (and the implementation simplified a bit) by using  (now supported in expressions) or the more recent , instead of   already too limited in value range (and actually not used in this template), and instead of  , as both are truncating their result towards zero, the equivalent of a   when their parameter is negative.

This template was written and optimized to avoid all conditional expressions and to reduce the template expansions to their strict minimum (avoiding also the inclusion of complex templates for computing cyclic modulos, or euclidian divisions and roundings towards minus infinity), because  still does not support temporary local variables to store the template parameters and reuse their current value without more expansions.

All problematic negative values are normally avoided by avoiding excessively negative parameter values (using negative values is safe for the day, hour, minute and second parameters, but not safe for the month and year parameters if their resulting month falls before March 4800 BC).

Examples

 * returns (proleptic) (in year 4801 BC), the result is still correct
 * returns (proleptic) (in year 4801 BC), date where the result is false (the returned JD is too large by 365 days)
 * returns (proleptic) (in year 4800 BC), the result is still correct
 * returns (proleptic) (in year 4800 BC), first Gregorian date where the result is warrantied to be correct
 * returns (proleptic) (in year 4800 BC), same date at noon
 * returns (proleptic) (in year 4800 BC), tests the 1 day increment
 * returns (proleptic) (in year 4714 BC)
 * returns (proleptic) (in year 4714 BC)
 * returns (proleptic) (in year 1 BC)
 * returns (proleptic)
 * returns (proleptic) (Julian Anno Domini, first day in proleptic Julian year 1 AD, or December 30 in proleptic Gregorian year 1 BC)
 * returns (proleptic)
 * returns (proleptic) (Gregorian Anno Domini, in proleptic Gregorian year 1 AD, or January 3 in proleptic Julian year 1 AD)
 * returns (proleptic) (last day of Julian leap year 200 AD, not leap in the proleptic Gregorian calendar)
 * returns (proleptic) (first day where the Julian and proleptic Gregorian calendars are equivalent)
 * returns (proleptic) (last day where the Julian and proleptic Gregorian calendars are equivalent)
 * returns (proleptic) (first day of difference between the Julian and proleptic Gregorian calendars, in leap Julian year 300 AD, not leap in the proleptic Gregorian calendar)
 * returns (proleptic) (spring equinox observed at the Christian First Council of Nicaea, taken as a reference for aligning the Julian calendar to the proleptic Gregorian)
 * returns (proleptic) (last proleptic Gregorian day, actually the 4th of October in the Julian calendar)
 * returns (first non proleptic Gregorian day, equals the 5th of October in the previous Julian calendar)
 * returns (start of epoch for the Reduced Julian Day, RJD)
 * returns (start of epoch for the Modified Julian Day, MJD)
 * returns (start of epoch for the NASA's Truncated Julian Day, TJD)
 * returns
 * returns
 * returns (start of epoch for the last NIST's Truncated Julian Day, TJD mod 10000)
 * returns
 * returns (the “Y2K bug's day” and millennium celebrations)
 * returns
 * returns
 * returns (last day of the 2nd millennium and of the 20th century in the Gregorian calendar)
 * returns (first day of the 3rd millennium and of the 21st century in the Gregorian calendar)
 * returns (start of epoch for the current NIST's Truncated Julian Day, TJD mod 10000)
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns
 * returns (10000 years lapse)
 * returns
 * returns (one trillion seconds lapse)
 * returns (maximum date of JavaScript; 100 million days lapse from Unix)