Post Reply 
days-between-dates Solver equation for 17b
10-08-2018, 10:33 PM (This post was last modified: 10-09-2018 09:33 PM by Albert Chan.)
Post: #21
RE: days-between-dates Solver equation for 17b
(10-08-2018 09:13 PM)Dieter Wrote:  what's wrong with the shorter and less complicated standard formula for the Julian-Gregorian difference?

Quote:...y/100 – y/400 – 2 days

So for year –4712 that's simply –48 – (–12) – 2 = –38.

That is good ! (above "/" meant floor division. To be safe, for month < 3, set y = y - 1) Smile

I were using 3rd century calendar match trivia. -2 days for "zero" century is simpler
X = 0,1,2,3, 4,5,6,7 ... => days apart = -2,-2,-1,0, 1,1,2,3 ... = (1,1,2,3, 4,4,5,6 ...) - 3

--> Days apart = (floor(X/4) - 1) * 3 + max(X % 4, 1)

For X = 21 = 5 * 4 + 1, Days apart = 4 * 3 + 1 = 13
For X = -47 = -12 * 4 + 1, Days apart = -13 * 3 + 1 = -38

Update: this is faster, Days apart = floor(0.75 X) - 2
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)