ordinal date

{{Short description|Date written as number of days since first day of year}}

{{inline|date=July 2019}}

{{Infobox

| title = {{nobreak|Today's date (UTC)}} {{nobreak|(in ISO 8601 notation) is:}}

[{{purge|refresh}}]

| label1 = Date

| data1 = {{ISO date}}

| label2 = Ordinal date

| data2 = {{CURRENTYEAR}}-{{padleft:{{#expr:{{#time: z}}+1}}|3}}

}}

Image:Cygnus 1 releasing seen from Mission Control (cropped) - clock board detail.jpg's board with time data, displaying coordinated universal time with ordinal date (without year) prepended, on October{{nbsp}}22, 2013 {{nobr|(i.e.2013-295)}} |alt= The top line of the board reads GMT 295: 11:31:54 (GMT was a synonym for UTC).]]

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 {{mono|JD}}, or {{mono|JDATE}}, 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 {{mono|JDN}}, 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",{{Cite web |last=Hynes |first=John |title=A summary of time formats and standards |url=https://web.archive.org/web/20220816033024/http://www.decimaltime.hynes.net/p/dates.html |access-date=2011-02-09 |website=www.decimaltime.hynes.net}} 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.{{Cite web |title=International standard date and time notation |url=https://www.cl.cam.ac.uk/~mgk25/iso-time.html |access-date=2024-05-01 |website=Department of Computer Science and Technology, University of Cambridge}}

Calculation

{{Original research |section |date=August 2019}}

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 {{mvar|O}} are presented. The inputs taken are integers {{mvar|y}}, {{mvar|m}} and {{mvar|d}}, 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 {{math| i {{=}} 1 .. m - 1}}, add the length of month {{mvar|i}} 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.{{cite web |url=https://www.atmos.anl.gov/ANLMET/OrdinalDay.txt |title=Table of ordinal day number for various calendar dates. |access-date=2021-04-08}}

= 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 {{mvar|m}} is changed to {{math|m + 12}} if {{math| m ≤ 2}}. It can be shown (see below) that for a month-number {{mvar|m}}, the total days of the preceding months is equal to {{math|⌊(153 * (m − 3) + 2) / 5⌋}}. As a result, the March 1-based ordinal day number is {{math|1=OMar = ⌊(153 × (m − 3) + 2) / 5⌋ + d}}.

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 {{sfrac|153|5}} 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 {{math|m ≤ 12}} (March through December), {{nowrap|{{math| O {{=}} OMar + 59 + isLeap(y)}} ,}} where {{math|isLeap}} is a function returning 0 or 1 depending whether the input is a leap year.
  • For January and February, two methods can be used:
  • # The trivial method is to skip the calculation of {{math|OMar}} and go straight for {{math| O {{=}} d}} for January and {{math| O {{=}} d + 31}} for February.
  • # The less redundant method is to use {{math| O {{=}} OMar − 306}}, 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 = \left \lfloor 63.2 n - 91.4 \right \rfloor

giving consecutive differences of 63 (9 weeks) for {{nowrap|{{mvar|n}} {{=}} 2,}} 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 = \left \lfloor 63.2 n - 56+0.2 \right \rfloor

and with m and d interchanged

:O = \left\lfloor 63.2 n - 56 + 119 - 0.4 \right\rfloor

giving a difference of 119 (17 weeks) for {{nowrap|{{mvar|n}} {{=}} 2}} (difference between 5/9 and 9/5), and also for {{nowrap|{{mvar|n}} {{=}} 3}} (difference between 7/11 and 11/7).

Table

class="wikitable" style="text-align:center;"

! 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

| 0 || 31 || 59 || 90 || 120 || 151 || 181 || 212 || 243 || 273 || 304 || 334 || 3

Leap years

| 0 || 31 || 60 || 91 || 121 || 152 || 182 || 213 || 244 || 274 || 305 || 335 || 2

Algorithm

| colspan="13"| 30 (m - 1) + \left \lfloor 0.6 (m + 1) \right \rfloor - i

For example, the ordinal date of April 15 is {{nowrap|90 + 15 {{=}} 105}} in a common year, and {{nowrap|91 + 15 {{=}} 106}} in a leap year.

Month–day

{{original research|section|date=August 2019}}

The number of the month and date is given by

:m = \left \lfloor od/30 \right \rfloor + 1

:d = \bmod\!\! (od, 30) + i - \left \lfloor 0.6 (m + 1) \right \rfloor

the term \bmod\!\! (od, 30) can also be replaced by od - 30 (m - 1) with od the ordinal date.

  • Day 100 of a common year:

::m = \left \lfloor 100/30 \right \rfloor + 1 = 4

::d = \bmod\!\! (100, 30) + 3 - \left \lfloor 0.6 (4 + 1) \right \rfloor = 10 + 3 - 3 = 10

:April 10.

  • Day 200 of a common year:

::m = \left \lfloor 200/30 \right \rfloor + 1 = 7

::d = \bmod\!\! (200, 30) + 3 - \left \lfloor 0.6 (7 + 1) \right \rfloor = 20 + 3 - 4 = 19

:July 19.

  • Day 300 of a leap year:

::m = \left \lfloor 300/30 \right \rfloor + 1 = 11

::d = \bmod\!\! (300, 30) + 2 - \left \lfloor 0.6 (11 + 1)\right \rfloor = 0 + 2 - 7 = - 5

:November - 5 = October 26 (31 - 5).

Helper conversion table

class="wikitable" style="float:left"

! ord.
date !! common
year !! leap
year

001colspan=2 | {{0}}1 Jan
010colspan=2 | 10 Jan
020colspan=2 | 20 Jan
030colspan=2 | 30 Jan
032colspan=2 | {{0}}1 Feb
040colspan=2 | {{0}}9 Feb
050colspan=2 | 19 Feb
060{{0}}1 Mar29 Feb
061{{0}}2 Mar{{0}}1 Mar
07011 Mar10 Mar
08021 Mar20 Mar
09031 Mar30 Mar
091{{0}}1 Apr31 Mar
092{{0}}2 Apr{{0}}1 Apr
10010 Apr{{0}}9 Apr

class="wikitable" style="float:left"

! ord.
date !! comm.
year !! leap
year

11020 Apr19 Apr
12030 Apr29 Apr
121{{0}}1 May30 Apr
122{{0}}2 May{{0}}1 May
13010 May{{0}}9 May
14020 May19 May
15030 May29 May
152{{0}}1 Jun31 May
153{{0}}2 Jun{{0}}1 Jun
160{{0}}9 Jun{{0}}8 Jun
17019 Jun18 Jun
18029 Jun28 Jun
182{{0}}1 Jul30 Jun
183{{0}}2 Jul{{0}}1 Jul
190{{0}}9 Jul{{0}}8 Jul

class="wikitable" style="float:left"

! ord.
date !! comm.
year !! leap
year

20019 Jul18 Jul
21029 Jul28 Jul
213{{0}}1 Aug31 Jul
214{{0}}2 Aug{{0}}1 Aug
220{{0}}8 Aug{{0}}7 Aug
23018 Aug17 Aug
24028 Aug27 Aug
244{{0}}1 Sep31 Aug
245{{0}}2 Sep{{0}}1 Sep
250{{0}}7 Sep{{0}}6 Sep
26017 Sep16 Sep
27027 Sep26 Sep
274{{0}}1 Oct30 Sep
275{{0}}2 Oct{{0}}1 Oct
280{{0}}7 Oct{{0}}6 Oct

class="wikitable" style="float:left"

! ord.
date !! comm.
year !! leap
year

29017 Oct16 Oct
30027 Oct26 Oct
305{{0}}1 Nov31 Oct
306{{0}}2 Nov{{0}}1 Nov
310{{0}}6 Nov{{0}}5 Nov
32016 Nov15 Nov
33026 Nov25 Nov
335{{0}}1 Dec30 Nov
336{{0}}2 Dec{{0}}1 Dec
340{{0}}6 Dec{{0}}5 Dec
35016 Dec15 Dec
36026 Dec25 Dec
36531 Dec30 Dec
366{{N/A}}31 Dec

{{-}}

See also

References

{{Reflist}}

{{DEFAULTSORT:Ordinal Date}}

Category:Calendars

Category:Ordinal numbers