# [ntp:questions] Understanding MJD in NTPv4 test cases

antony.arciuolo at oooii.com antony.arciuolo at oooii.com
Wed Aug 15 19:51:52 UTC 2012

```In http://www.ietf.org/rfc/rfc5905.txt and http://www.eecis.udel.edu/~mills/database/reports/ntp4/ntp4.pdf

Figure 4: Interesting Historic NTP Dates/Table 2: Interesting Historic NTP Dates

It seems to me that all MJD values in the table are calculated using Gregorian calculations all the way back. If I put in an "if before Gregorian was used" to do a different leap day calculation, then none of the pre-Gregorian values come out correctly.

This is all true EXCEPT for the first test, the Julian Day Number Epoch. The document describes what should be "zero" for MJD, i.e. the exact constant that the offset is from regular JD. Using the Gregorian calculation for Julian Days, the value for Jan 1, -4712 is 38, not 0. Thus the MJD I get is -2399963, not -2400001. That's way more than any precision/noon v. midnight would produce.

Why is that first date different algorithmically, if the test values are to be believed? It's not a Julian v. Gregorian thing because I can generate the other BCE dates consistently.

Am I missing something? I feel like either the first MJD in the table is incorrect, or all BCE values are incorrectly calculated using Gregorian math in a non-Gregorian era.

I am using code from http://www.tondering.dk/claus/calendar.html AND http://bowie.gsfc.nasa.gov/time/julian.txt (ported to C) for JDN calc and they are always self consistent (I do a assert(JDN1 == JDN2) to be sure I've got the calcs right). I also have a 3rd I did right from http://en.wikipedia.org/wiki/Julian_day, but that too produces 38.

I can only get 0 JDN, thus -2400001 MJD with a non-Gregorian calculation, but then all BCE calcs + "Last day Julian" fail (the CE tests after "Last day Julian" all pass.

Please, can someone shed some light on what I am missing? What are the rules NTP uses for calculating JDN?

```