How I used cal to research days in different years

Yesterday afternoon I posted Date bug in Entourage 2008 causes birthday information loss on the Entourage Help Blog. This post required me to do some detailed testing with dates ranging all the way from 1899 to 2050 and determining the specific days of the week for these dates.

Enter the cal command in the Terminal!


I read about the cal command in a post on MacOSXHints.com about ncal and it has become one of my favorite utilities.

Simply put, cal is a calendar tool. I can view a single month, a full year or dates for any year in seconds without confusing calculations or having to scroll to a date in a calendar application such as Microsoft Entourage or Apple’s iCal.

Quick: what are the days for April 12, 1985; April 12, 2008; and April 12 2058? Friday, Saturday and Friday again.

This took me less than a few seconds to type a simple command to get the answer.

Open the Terminal application found in /Applications/Utilities and simply type cal followed by the return key. This will give you this month’s calendar.

     June 2008
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

Next, type cal 1979 followed by return and you’ll see the entire 12-month calendar for 1979.

                            1979
January               February               March
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6               1  2  3               1  2  3
7  8  9 10 11 12 13   4  5  6  7  8  9 10   4  5  6  7  8  9 10
14 15 16 17 18 19 20  11 12 13 14 15 16 17  11 12 13 14 15 16 17
21 22 23 24 25 26 27  18 19 20 21 22 23 24  18 19 20 21 22 23 24
28 29 30 31           25 26 27 28           25 26 27 28 29 30 31
April                  May                   June
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7         1  2  3  4  5                  1  2
8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
29 30                 27 28 29 30 31        24 25 26 27 28 29 30
July                 August              September
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7            1  2  3  4                     1
8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
30
October               November              December
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa
1  2  3  4  5  6               1  2  3                     1
7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
30 31

Type cal June 1979 followed by return and you’ll see just the month of June for 1979.

     June 1979
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

To see Julian days (days numbered from 1-365) for June 1979 type cal -j June 1979.

         June 1979
Su  Mo  Tu  We  Th  Fr  Sa
152 153
154 155 156 157 158 159 160
161 162 163 164 165 166 167
168 169 170 171 172 173 174
175 176 177 178 179 180 181

For my April 12 quiz at the top I simply string three cal commands together using a semi-colon: cal April 1985 ; cal April 2008 ; cal April 2058.

     April 1985
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
April 2008
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
April 2058
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

Using the MacOSXHints.com link I provided earlier you can set up ncal for more calendar tricks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s