Ordinal date

From testwiki
Jump to navigation Jump to search

Template:Short description Template:Inline

Template:InfoboxTemplate:Redirect

 The top line of the board reads GMT 295: 11:31:54 (GMT was a synonym for UTC).
Mission control center's board with time data, displaying coordinated universal time with ordinal date (without year) prepended, on OctoberTemplate:Nbsp22, 2013 Template:Nobr

An ordinal date is a calendar date typically consisting of a year and an ordinal number, ranging between 1 and 366 (starting on January 1), representing the multiples of a day, called day of the year or ordinal day number (also known as ordinal day or day number). The two parts of the date can be formatted as "YYYY-DDD" to comply with the ISO 8601 ordinal date format. The year may sometimes be omitted, if it is implied by the context; the day may be generalized from integers to include a decimal part representing a fraction of a day.

Nomenclature

Ordinal date is the preferred name for what was formerly called the "Julian date" or Template:Mono, or Template:Mono, which still seen in old programming languages and spreadsheet software. The older names are deprecated because they are easily confused with the earlier dating system called 'Julian day number' or Template:Mono, which was in prior use and which remains ubiquitous in astronomical and some historical calculations.

The U.S. military sometimes uses a system they call the "Julian date format",[1] which indicates the year and the day number (out of the 365 or 366 days of the year). For example, "11 December 1999" can be written as "1999345" or "99345", for the 345th day of 1999.[2]

Calculation

Template:Original research Computation of the ordinal day within a year is part of calculating the ordinal day throughout the years from a reference date, such as the Julian date. It is also part of calculating the day of the week, though for this purpose modulo 7 simplifications can be made.

In the following text, several algorithms for calculating the ordinal day Template:Mvar are presented. The inputs taken are integers Template:Mvar, Template:Mvar and Template:Mvar, for the year, month, and day numbers of the Gregorian or Julian calendar date.

Trivial methods

The most trivial method of calculating the ordinal day involves counting up all days that have elapsed per the definition:

  1. Let O be 0.
  2. From Template:Math, add the length of month Template:Mvar to O, taking care of leap year according to the calendar used.
  3. Add d to O.

Similarly trivial is the use of a lookup table, such as the one referenced.[3]

Zeller-like

The table of month lengths can be replaced following the method of encoding the month-length variation in Zeller's congruence. As in Zeller, the Template:Mvar is changed to Template:Math if Template:Math. It can be shown (see below) that for a month-number Template:Mvar, the total days of the preceding months is equal to Template:Math. As a result, the March 1-based ordinal day number is Template:Math.

The formula reflects the fact that any five consecutive months in the range March–January have a total length of 153 days, due to a fixed pattern 31–30–31–30–31 repeating itself twice. This is similar to encoding of the month offset (which would be the same sequence modulo 7) in Zeller's congruence. As Template:Sfrac is 30.6, the sequence oscillates in the desired pattern with the desired period 5.

To go from the March 1 based ordinal day to a January 1 based ordinal day:

  • For Template:Math (March through December), Template:Nowrap where Template:Math is a function returning 0 or 1 depending whether the input is a leap year.
  • For January and February, two methods can be used:
    1. The trivial method is to skip the calculation of Template:Math and go straight for Template:Math for January and Template:Math for February.
    2. The less redundant method is to use Template:Math, where 306 is the number of dates in March through December. This makes use of the fact that the formula correctly gives a month-length of 31 for January.

"Doomsday" properties:

With m=2n and d=m gives

O=⌊63.2n−91.4⌋

giving consecutive differences of 63 (9 weeks) for Template:Nowrap 3, 4, 5, and 6, i.e., between 4/4, 6/6, 8/8, 10/10, and 12/12.

m=2n+1 and d=m+4 gives

O=⌊63.2n−56+0.2⌋

and with m and d interchanged

O=⌊63.2n−56+119−0.4⌋

giving a difference of 119 (17 weeks) for Template:Nowrap (difference between 5/9 and 9/5), and also for Template:Nowrap (difference between 7/11 and 11/7).

Table

To the day of 13
Jan
14
Feb
3
Mar
4
Apr
5
May
6
Jun
7
Jul
8
Aug
9
Sep
10
Oct
11
Nov
12
Dec
i
Add 03159901201511812122432733043343
Leap years 03160911211521822132442743053352
Formula 30(m−1)+⌊0.6(m+1)⌋−i

For example, the ordinal date of April 15 is Template:Nowrap in a common year, and Template:Nowrap in a leap year.

Month–day

Template:Original research The number of the month and date is given by

m=⌊od/30⌋+1
d=mod(od,30)+i−⌊0.6(m+1)⌋

the term mod(od,30) can also be replaced by od−30(m−1) with od the ordinal date.

  • Day 100 of a common year:
m=⌊100/30⌋+1=4
d=mod(100,30)+3−⌊0.6(4+1)⌋=10+3−3=10
April 10.
  • Day 200 of a common year:
m=⌊200/30⌋+1=7
d=mod(200,30)+3−⌊0.6(7+1)⌋=20+3−4=19
July 19.
  • Day 300 of a leap year:
m=⌊300/30⌋+1=11
d=mod(300,30)+2−⌊0.6(11+1)⌋=0+2−7=−5
November - 5 = October 26 (31 - 5).

Helper conversion table

ord.
date
common
year
leap
year
001Template:01 Jan
01010 Jan
02020 Jan
03030 Jan
032Template:01 Feb
040Template:09 Feb
05019 Feb
060Template:01 Mar29 Feb
061Template:02 MarTemplate:01 Mar
07011 Mar10 Mar
08021 Mar20 Mar
09031 Mar30 Mar
091Template:01 Apr31 Mar
092Template:02 AprTemplate:01 Apr
10010 AprTemplate:09 Apr
ord.
date
comm.
year
leap
year
11020 Apr19 Apr
12030 Apr29 Apr
121Template:01 May30 Apr
122Template:02 MayTemplate:01 May
13010 MayTemplate:09 May
14020 May19 May
15030 May29 May
152Template:01 Jun31 May
153Template:02 JunTemplate:01 Jun
160Template:09 JunTemplate:08 Jun
17019 Jun18 Jun
18029 Jun28 Jun
182Template:01 Jul30 Jun
183Template:02 JulTemplate:01 Jul
190Template:09 JulTemplate:08 Jul
ord.
date
comm.
year
leap
year
20019 Jul18 Jul
21029 Jul28 Jul
213Template:01 Aug31 Jul
214Template:02 AugTemplate:01 Aug
220Template:08 AugTemplate:07 Aug
23018 Aug17 Aug
24028 Aug27 Aug
244Template:01 Sep31 Aug
245Template:02 SepTemplate:01 Sep
250Template:07 SepTemplate:06 Sep
26017 Sep16 Sep
27027 Sep26 Sep
274Template:01 Oct30 Sep
275Template:02 OctTemplate:01 Oct
280Template:07 OctTemplate:06 Oct
ord.
date
comm.
year
leap
year
29017 Oct16 Oct
30027 Oct26 Oct
305Template:01 Nov31 Oct
306Template:02 NovTemplate:01 Nov
310Template:06 NovTemplate:05 Nov
32016 Nov15 Nov
33026 Nov25 Nov
335Template:01 Dec30 Nov
336Template:02 DecTemplate:01 Dec
340Template:06 DecTemplate:05 Dec
35016 Dec15 Dec
36026 Dec25 Dec
36531 Dec30 Dec
366Template:N/A31 Dec

Template:-

See also

References

Template:Reflist