Template talk:JULIANDAY

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).