Calendar Date ±N Days In the Relative Past Or FutureFrom Any Given Starting Date Start Date ±Y  M  D:                 ±N:  day Calendar Mode:    Julian            Gregorian
Starting Date
 G 2017      April Sun Mon Tue Wed Thu Fri Sat 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
Ending Date (relative future)
 G 2017      April Sun Mon Tue Wed Thu Fri Sat 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

 CALENDAR DATE ±N DAYS IN PAST OR FUTURE FROM STARTING DATE ============================================================ Starting Date Arguments ISOymdA = 20170429 (April 29, 2017) yA = 2017 mA = 04 dA = 29 (Saturday) CalMode = 1 (Gregorian calendar) -------------------- 2017 April Su Mo Tu We Th Fr Sa                    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 -------------------- JDA = 2457873 (Saturday) ============================================================ Number Of Days Argument N = 1 day (relative future) ============================================================ JD Number Of Ending Date JDB = (JDA + N) = 2457874 (Sunday) ============================================================ Ending date ISOymdB = 20170430 (ISO integer-encoded ending date) yB = 2017 mB = 04 dB = 30 (Sunday) -------------------- 2017 April Su Mo Tu We Th Fr Sa                    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 --------------------

 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. First, compute the simple JD number for the starting date (JDA). Then apply ±N days to the JD of the starting date (JDA) to obtain the JD of the ending date (JDB). 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, 1776was August 4th, 1806.

© PHP Science Labs - 2017