Many people say the world will end on 12/21/2012 G (dates in our own calendar, the Gregorian calendar, carry the suffix G). Where does this exact date come from? Most people are simply repeating what they have heard, yet there is a line of reasoning behind it. The idea comes from the Maya civilization and their calendar, the Mesoamerican Long Count calendar (dates in this calendar carry the suffix MLC). The Maya are said to have believed that three failed worlds preceded the current, fourth one. The previous world is said to have ended on 13.0.0.0.0 MLC. Because that date is also the beginning of the current world, the calendar resets and the moment is written as 0.0.0.0.0 MLC. When we again reach 13.0.0.0.0 MLC, history may repeat itself and the current world may end. Given a correspondence between an MLC date and a date in another calendar, we want to know how many days remain until the end of the world.
To work this out we need two more calendars, but first: what is an MLC date? An MLC date is simply a count of the days since the creation of the current world. It is a base-20 number whose digits are separated by dots, except that the second digit counting from the right is base-18. For example, the day before the end of the current world is 12.19.19.17.19 MLC. Concretely, an MLC date written $b.k.t.u.d$ (most significant digit first) equals $b\cdot 144000 + k\cdot 7200 + t\cdot 360 + u\cdot 20 + d$ days since 0.0.0.0.0 MLC, and 13.0.0.0.0 MLC equals $13\cdot 144000 = 1872000$ days.
Why two more calendars? When astronomers line up Maya astronomical records with the known dates of astronomical events, they identify each known date by its Julian Day Number (suffix JDN). JDN is convenient for arithmetic because, like MLC, it is a count of days since a starting day, 0 JDN. Since we want the number of days until the end of the world, we only need the JDN of today, 5/6/2012 G, and the JDN of the end of the world, 13.0.0.0.0 MLC. The JDN of the end of the world is easy to obtain from the MLC date and JDN of a single astronomical event. Obtaining the JDN of today's date is harder and needs yet another calendar.
0 JDN is defined using the Julian calendar (suffix J). History books that mention events before 10/15/1582 G usually mean Julian dates, because the Gregorian calendar was only adopted at 10/5/1582 J, at which point 10 days were skipped and the count resumed at 10/15/1582 G. The Julian calendar is identical to the Gregorian calendar except for a simpler leap-year rule (and that 10-day skip). A year Y is a leap year when:
Julian: Y % 4 == 0
Gregorian: (Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0
0 JDN equals 1/1/4713 BCE J (BCE, "before common era", denotes dates before 1/1/1 J; these behave the same except that the year counts down toward 1 BCE J, after which comes the first common-era year, 1 J). BCE dates do not follow the ordinary leap-year rule, because 4 years before 1/1/4 J is 1/1/1 BCE J, so the rule becomes:
BCE J: (Y - 1) % 4 == 0
Using this we can count the days from 0 JDN to 10/5/1582 J, then use the Gregorian rules to count the days from 10/15/1582 G to today, and add the two counts to get today's JDN:
# of Julian days = 4713 * 365
+ (4713-1) / 4 + 1 // leap-days
+ 1581 * 365
+ 1581 / 4 // leap-days
+ 5*31 + 3*30 + 28 + 4 // days in 1582
= 2299161
# of Gregorian days = ( ((2012-1)-1200) * 365 // days since 1200
+ ((2012-1)-1200) / 4 // overcount leap-days
- ((2012-1)-1200) / 100 // adjust count
+ ((2012-1)-1200) / 400 // adjust count
+ 2*31 + 30 + 29 + 6 ) // days in 2012
- ( ((1582-1)-1200) * 365 // days from 1200 to 1582
+ ((1582-1)-1200) / 4
- ((1582-1)-1200) / 100
+ ((1582-1)-1200) / 400
+ 5*31 + 3*30 + 28 + 14 ) // days in 1582
= 156894
Total = 2299161 + 156894
= 2456055
This total counts 0 JDN itself, so 5/6/2012 G is equivalent to 2456054 JDN.
The first line contains the number K of data sets. Each of the K data sets is given on the following two lines:
For a valid Long Count date the four base-20 digits satisfy $0 \le \text{digit} \le 19$, and the second-least-significant digit (the uinal) satisfies $0 \le u \le 17$. The date's value in days is the weighted sum $b\cdot 144000 + k\cdot 7200 + t\cdot 360 + u\cdot 20 + d$ defined above.
For each data set, print a line Data Set x:, where x is the data set's number (starting from 1). On the next line print the number of days remaining until the end of the world, assuming the given JDN for the astronomical event is correct. If that number is negative, print It's a hoax! instead; if it is exactly 0, print Panic! instead. Separate consecutive data sets with a blank line.