Calendar Date ±N Days In the Relative Past Or Future
From Any Given Starting Date
Start Date ±Y  M  D:                 ±N:  day
Calendar Mode:    Julian            Gregorian
Starting Date
G 2017      March
SunMonTueWedThuFriSat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Ending Date (relative future)
G 2017      March
SunMonTueWedThuFriSat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  




Computing The Date N Days In The Past Or Future

Given any arbitrary starting date and calendar mode (ymdA, CalMode), we may want to know what the ending calendar date (ISOymdB) was or will be (±N) in the relative past or future.  To do this, we combine the JD computation function with the inverse JD function.

  1. First, compute the simple JD number for the starting date (JDA).


  2. Then apply ±N days to the JD of the starting date (JDA) to obtain the JD of the ending date (JDB).


  3. Finally, call the inverse JD function to compute the ISO integer-encoded end date (ISOymdB) corresponding to (JDB, CalMode).

Algorithm 8:

Given starting date and calendar mode (ISOymdA, CalMode), compute the calendar date (ISOymdB) ±N day(s) in relative past or future.


 JDA = JD_For_ISOymd (ISOymdA, CalMode)

 JDB = JDA + N

 ISOymdB = ISOymd_For_JD (JDB, CalMode)



EXAMPLE:
Given the starting date of July 4th, 1776 (Gregorian), what was the calendar date exactly
(N = 10987) days later?


 CalMode = 1 (Gregorian)

 ISOymdA = 17760704 = July 4th, 1776 AD,  for which JDA = 2369916

     JDB =  JDA + N = 2369916 + (10987) = 2380903
 


Then, given JDB = 2380903, the inverse JD function returns:
ISOymdB  =  18060804 (August 4th, 1806 AD)

So, the Gregorian calendar date exactly +10987 days from July 4th, 1776
was August 4th, 1806.



© PHP Science Labs - 2017