Template talk:JULIANDAY

From Wikipedia, the free encyclopedia

Template:JULIANDAY (edit talk links history)

The formula used is in this template is :

  (((year * 12 + month + 57608.5 round 0) / 12 - 1.5 round 0) * 1461 / 4 - 0.5 round 0)
- (((year * 12 + month + 57608.5 round 0) / 12 - 1.5 round 0) / 100 - 0.5 round 0)
+ (((year * 12 + month + 57608.5 round 0) / 12 - 1.5 round 0) / 400 - 0.5 round 0)
+ ((            (month + 57608.5 round 0) mod 12 + 4) * 153 / 5 - 0.5 round 0)
+ day + hour / 24 + minute / 1440 + second / 86400
- 32167.5

The formulas allows using date elements that are out of range, for date computing (for example when adding or substracting any number of months, and it works even if these months span one or more leap years). You can also specify hours out of the normal range 0..23, minutes seconds out of 0..59. And days of month out of the normal month range (1..31), so you can also add or substract any number of days. It ignores leap seconds (the returned JD considers all days having 24 hours exactly).

[edit] Testing subst

Optional substitution works if all optional parameters are specified, and the optional subst parameter is given as in:
{{subst:JULIANDAY|2006|12|31|23|59|59|subst=subst:}} = 2454101.49999
Without substitution:
{{JULIANDAY|2006|12|31|23|59|59}} = 2454101.4999884

[edit] Test suite

Adapted from m:Template talk:YMD2MJD
Code Result MJD JD REXX
{{JULIANDAY|0000|03|01|0}} = 1721119.5 -678881 1721119.5 -306
{{JULIANDAY|0001|01|31|0}} = 1721455.5 -678545 1721455.5 30
{{JULIANDAY|0001|02|01|0}} = 1721456.5 -678544 1721456.5 31
{{JULIANDAY|0001|02|28|0}} = 1721483.5 -678517 1721483.5 58
{{JULIANDAY|0001|03|01|0}} = 1721484.5 -678516 1721484.5 59
{{JULIANDAY|0001|08|31|0}} = 1721667.5 -678333 1721667.5 242
{{JULIANDAY|0001|09|01|0}} = 1721668.5 -678332 1721668.5 243
{{JULIANDAY|0004|02|29|0}} = 1722579.5 -677421 1722579.5 1154
{{JULIANDAY|0004|03|01|0}} = 1722580.5 -677420 1722580.5 1155
{{JULIANDAY|1259|03|02|0}} = 2180960.5 -219040 2180960.5 459535
{{JULIANDAY|1516|12|30|0}} = 2275130.5 -124870 2275130.5 553705
{{JULIANDAY|1582|10|15|0}} = 2299160.5 -100840 2299160.5 577735
{{JULIANDAY|1752|09|14|0}} = 2361221.5 -38779 2361221.5 639796
{{JULIANDAY|1858|11|17|0}} = 2400000.5 0 2400000.5 678575
{{JULIANDAY|1895|02|28|0}} = 2413252.5 13252 2413252.5 691827
{{JULIANDAY|1895|03|01|0}} = 2413253.5 13253 2413253.5 691828
{{JULIANDAY|1896|02|29|0}} = 2413618.5 13618 2413618.5 692193
{{JULIANDAY|1896|03|01|0}} = 2413619.5 13619 2413619.5 692194
{{JULIANDAY|1900|02|28|0}} = 2415078.5 15078 2415078.5 693653
{{JULIANDAY|1900|03|01|0}} = 2415079.5 15079 2415079.5 693654
{{JULIANDAY|1970|01|01|0}} = 2440587.5 40587 2440587.5 719162
{{JULIANDAY|2000|02|29|0}} = 2451603.5 51603 2451603.5 730178
{{JULIANDAY|2000|03|01|0}} = 2451604.5 51604 2451604.5 730179
{{JULIANDAY|2738|11|28|0}} = 2721424.5 321424 2721424.5 999999
Examples adapted from Template:YMD2MJD (edit talk links history) on Meta:
{{JULIANDAY|1900|02|28}} = 2415079, last day of February 1900
{{JULIANDAY|1900|02|29}} = 2415080, bogey but okay
{{JULIANDAY|1900|03|01}} = 2415080, no leap year
{{JULIANDAY|1900|02|30}} = 2415081, bogey but okay
{{JULIANDAY|1900|03|02}} = 2415081
{{JULIANDAY|2000|02|29}} = 2451604, last day of February 2000
{{JULIANDAY|2000|02|30}} = 2451605, bogey but okay
{{JULIANDAY|2000|03|01}} = 2451605, leap year
{{JULIANDAY|2000|02|31}} = 2451606, bogey but okay
{{JULIANDAY|2000|03|02}} = 2451606
{{JULIANDAY|2008|06|08}} = 2454626

[edit] Better examples

Where do I go to get the current day of the year? Like is today the 108th day of 2008 or what? --Uncle Ed (talk) 17:27, 17 April 2008 (UTC)