Pages

Tuesday, April 10, 2012

Easter day calculation and some interesting things with ncal

Easter date is not constant. It changes every year. For several years I had no idea on how to calculate the Easter date in an year. If you could calculate when will be the Easter fall on an year you can easily get a brief idea about another related holidays like Palm Sunday, Maundy Thursday, Holy Saturday, Good Friday, Easter Monday.
In Christian calendar the date of Easter has prime importance. The First Council of Nicaea established the date of Easter as the first Sunday after the full moon following the northern hemisphere's vernal equinox. According to the Catholic church, the equinox is on 21 March, and the "Full Moon" is not necessarily the astronomically correct date. The date of Easter therefore varies between 22 March and 25 April. Eastern Christianity bases its calculations on the Julian calendar whose 21 March corresponds, during the 21st century, to 3 April in the Gregorian calendar, in which the celebration of Easter therefore varies between 4 April and 8 May.
Sometime back I was checking the man page of ncal. The man page says “The cal utility displays a simple calendar in traditional format and ncal offers an alternative layout, more options and the date of easter.” Yes, you can calculate the easter day on AD 4012 now with this ncal utility. Just type the following command in the GNU/Linux console.
ncal -e 4012
In the next moment, ncal will tell you the result.
On 4012, Easter will be on 22 April 4012
And do you want to know when will be the orthodox Easter on the same day? The command has a little difference.
ncal -o 4012
The orthodox Easter on 4012 is on 6 May 4012
Want to look a weird calendar year according to the Gregorian system. Just look the calendar of 1752 calendar using cal command.
cal -y 1752

And just look on the month of September. Which day comes after September 2nd? Why? The answer will get from the man pages of cal. Type
man cal
Man page says "Assume the switch from Julian to Gregorian Calendar at the date associated with the country_code.  If not specified, ncal tries to guess the switch date from the local environment or falls back to September 2, 1752. This was when Great Britain and her colonies switched to the Gregorian Calendar"

That's the story of 1752 September. The smallest month in the Gregorian calendar system. But not all countries accepted Gregorian calendar system all of a sudden in one fine day. Some countries accepted it 1582, while some other countries accepted it centuries later. So how to find out when did Spain accepted Gregorian calendar system? Type the following command
ncal -p
Here is the result. Country code | Country name | Julian to Gregorian switch date.
 AL Albania        1912-11-30      IT Italy          1582-10-04
 AT Austria        1583-10-05      JP Japan          1918-12-18
 AU Australia      1752-09-02      LI Lithuania      1918-02-01
 BE Belgium        1582-12-14      LN Latin          9999-05-31
 BG Bulgaria       1916-03-18      LU Luxembourg     1582-12-14
 CA Canada         1752-09-02      LV Latvia         1918-02-01
 CH Switzerland    1655-02-28      NL Netherlands    1582-12-14
 CN China          1911-12-18      NO Norway         1700-02-18
 CZ Czech Republic 1584-01-06      PL Poland         1582-10-04
 DE Germany        1700-02-18      PT Portugal       1582-10-04
 DK Denmark        1700-02-18      RO Romania        1919-03-31
 ES Spain          1582-10-04      RU Russia         1918-01-31
 FI Finland        1753-02-17      SI Slovenia       1919-03-04
 FR France         1582-12-09      SE Sweden         1753-02-17
 GB United Kingdom 1752-09-02      TR Turkey         1926-12-18
 GR Greece         1924-03-09     *US United States  1752-09-02
 HU Hungary        1587-10-21      YU Yugoslavia     1919-03-04
 IS Iceland        1700-11-16
China, Albania, Bulgaria, Russia, Lithuania, Latvia, Japan, Slovenia, Yugoslavia, Romania, Greece, Turkey (sorted chronologically) accepted Gregorian calendar in the 20th century. Turkey was the last republic adopted Gregorian calendar in this list. Ok. lets try to get the Turkey's official calendar on 1926. Type the command in the terminal.
ncal -s TR 1926

In Turkey, the year 1926 was ended on December 18th! Cool, eh? In Greece they turned to Gregorian system on 1924 March. Lets try the following command
ncal -s GR 3 1924
And now let's see the 1924 March official calendar of Greece.
    March 1924
Mo     4 24 31
Tu     5 25
We     6 26
Th     7 27
Fr  1  8 28
Sa  2  9 29
Su  3 23 30
They lost two weeks in that March. Scary, no? And the most interesting calendar is 9999. I don't know what is the relevance of this. Lets check with two commands.
ncal -s LN 9999
With this command we will get the normal calendar on that year.
ncal -s LN -j 9999
With this command we can just figure how many days were in that year.
tom@debian:~$ ncal -s LN 9999
                                  9999
    January           February          March             April
Mo  1  8 15 22 29        5 12 19 26        5 12 19 26        2  9 16 23 30
Tu  2  9 16 23 30        6 13 20 27        6 13 20 27        3 10 17 24
We  3 10 17 24 31        7 14 21 28        7 14 21 28        4 11 18 25
Th  4 11 18 25        1  8 15 22        1  8 15 22 29        5 12 19 26
Fr  5 12 19 26        2  9 16 23        2  9 16 23 30        6 13 20 27
Sa  6 13 20 27        3 10 17 24        3 10 17 24 31        7 14 21 28
Su  7 14 21 28        4 11 18 25        4 11 18 25        1  8 15 22 29
    May               June              July              August
Mo     7 14 21 28                                           16 23 30
Tu  1  8 15 22 29                                           17 24 31
We  2  9 16 23 30                                           18 25
Th  3 10 17 24 31                                           19 26
Fr  4 11 18 25                                           13 20 27
Sa  5 12 19 26                                           14 21 28
Su  6 13 20 27                                           15 22 29
    September         October           November          December
Mo     6 13 20 27        4 11 18 25     1  8 15 22 29        6 13 20 27
Tu     7 14 21 28        5 12 19 26     2  9 16 23 30        7 14 21 28
We  1  8 15 22 29        6 13 20 27     3 10 17 24        1  8 15 22 29
Th  2  9 16 23 30        7 14 21 28     4 11 18 25        2  9 16 23 30
Fr  3 10 17 24        1  8 15 22 29     5 12 19 26        3 10 17 24 31
Sa  4 11 18 25        2  9 16 23 30     6 13 20 27        4 11 18 25
Su  5 12 19 26        3 10 17 24 31     7 14 21 28        5 12 19 26
tom@debian:~$ ncal -s LN -j 9999
                                  9999
    January                 February                March
Mo   1   8  15  22  29          36  43  50  57          64  71  78  85
Tu   2   9  16  23  30          37  44  51  58          65  72  79  86
We   3  10  17  24  31          38  45  52  59          66  73  80  87
Th   4  11  18  25          32  39  46  53          60  67  74  81  88
Fr   5  12  19  26          33  40  47  54          61  68  75  82  89
Sa   6  13  20  27          34  41  48  55          62  69  76  83  90
Su   7  14  21  28          35  42  49  56          63  70  77  84
    April                   May                     June
Mo      92  99 106 113 120     127 134 141 148
Tu      93 100 107 114     121 128 135 142 149
We      94 101 108 115     122 129 136 143 150
Th      95 102 109 116     123 130 137 144 151
Fr      96 103 110 117     124 131 138 145
Sa      97 104 111 118     125 132 139 146
Su  91  98 105 112 119     126 133 140 147
    July                    August                  September
Mo                             155 162 169             176 183 190 197
Tu                             156 163 170             177 184 191 198
We                             157 164             171 178 185 192 199
Th                             158 165             172 179 186 193 200
Fr                         152 159 166             173 180 187 194
Sa                         153 160 167             174 181 188 195
Su                         154 161 168             175 182 189 196
    October                 November                December
Mo     204 211 218 225     232 239 246 253 260         267 274 281 288
Tu     205 212 219 226     233 240 247 254 261         268 275 282 289
We     206 213 220 227     234 241 248 255         262 269 276 283 290
Th     207 214 221 228     235 242 249 256         263 270 277 284 291
Fr 201 208 215 222 229     236 243 250 257         264 271 278 285 292
Sa 202 209 216 223 230     237 244 251 258         265 272 279 286
Su 203 210 217 224 231     238 245 252 259         266 273 280 287
So there is only 292 days in that year, 73 days will be lost. June, July months are not in the picture. And 12 days of August also missing. People who follow Latin Calendar goes to sleep on 9999 March 31 will be woke up on August 13! Anyway, I still do not have any idea about the Latin Calendar system. I think this calendar is the Julian calendar. But who follows it still, why does it switch on 9999 March 31 to Gregorian system? Maybe, Julian calendar will be abandoned on 9999 March 31. I searched lots of web pages regarding this, but from nowhere I got satisfactory results.
And finally do you want to have a glance of the code of ncal which is done in "C". Here is the link. All of us may be heard about Julian calendar and Gregorian calendar. But how many of us know the minute calculations based on that? Just figure how deep the rabbit hole goes!

6 comments:

spotblog said...

Quite interesting. I heard about the Julian calendar and Gregorian calendar, but was not aware about the differences between them. Not familiar with commandline, but even tried it and the experience was so wonderful. The post is really useful. Thanks for that.

saju george said...

Very Informative. Good effort

hackingtom said...

Thank you spotblog. Thanks saju george. So happy that you read it. Planning to post something more deep about ncal and Gregorian calendar.

snapakyohan said...

Hackingtom, its no problem if they abandon the Julian calendar on 9999 March 31st. Me and you and the entire people live today will no longer exist on that day, so why should we bother about that:-) And I think the Julian calendar is still used by some eastern orthodox churches to calculate their easter dates. But I am not sure. Anyway this post will help the unix command newbies to find the wonders behind that pretty small utility - cal and ncal.

snapakyohan said...

Just want to say something more. I got the exact result what you could not get from the web. The Julian calendar still used by the Orthodox church in Russia. That's why ncal still gives the option -s LN. In the Julian calendar, the tropical year is approximated as 365¼ days = 365.25 days. This gives an error of 1 day in approximately 128 years. The approximation 365¼ is achieved by having 1 leap year every 4 years.Read more @ http://www.tondering.dk/claus/cal/julian.php

hackingtom said...

snapakyohan, thanks for the info. I guessed that the Julian calendar is being used by some orthodox churches. So I think when we use ncal with -o option it searches for the Julian calendar. Anyway thanks for the link.

Search.web