To trace the real story, try running man cal
yourself:
The Gregorian Reformation is assumed to have occurred in 1752 on the 3rd
of September. By this time, most countries had recognized the reforma-
tion (although a few did not recognize it until the early 1900’s.) Ten
days following that date were eliminated by the reformation, so the cal-
endar for that month is a bit unusual.
Then, if your history is sketchy, continue with Wikipedia for information about the changes introduced by Gregorian Calendar and it's history of adoption in various parts of the world:
The Gregorian calendar reform contained two parts, a reform of the Julian calendar as used up to Pope Gregory's time, together with a reform of the lunar cycle used by the Church along with the Julian calendar for calculating dates of Easter.
[...]
In addition to the change in the mean length of the calendar year from 365.25 days (365 days 6 hours) to 365.2425 days (365 days 5 hours 49 minutes 12 seconds), a reduction of 10 minutes 48 seconds per year, the Gregorian calendar reform also dealt with the past accumulated difference between these lengths.
[...]
Because of the Protestant Reformation, however, many Western European countries did not initially follow the Gregorian reform, and maintained their old-style systems. Eventually other countries followed the reform for the sake of consistency, but by the time the last adherents of the Julian calendar in Eastern Europe (Russia and Greece) changed to the Gregorian system in the 20th century, they had to drop 13 days from their calendars, due to the additional accumulated difference between the two calendars since 1582.
[...]
Britain and the British Empire (including the eastern part of what is now the United States) adopted the Gregorian calendar in 1752, by which time it was necessary to correct by 11 days. Wednesday, 2 September 1752 was followed by Thursday, 14 September 1752.
By the time Unix came along and reset the worlds clocks to start at January 1st, 1970 there was nothing to be done about the whole mess except pick a date to show the reset on. Since the world adopted the current Gregorian calendar system at varying times in different countries, the exact time to make this correction is somewhat arbitrary.
If you ever have a reason to count dates going back that far in your software, you will run into much more significant issues than just that one reset! The history of calendaring is full of surprises!
You could use sed
for that.
$ cal|sed -e '1n;s/\(..\)\(.\)/\1,\2/g'
May 2012
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, 31
1n
prints the first line and moves to the next. The replacement then takes the chars three by three and prints the first two followed by ,
then the third.
Best Answer
I don't know how to highlight the day in the year calendar
cal -y
with just regular expressions, but the reason your example was not working for single digit dates is because$(date +%e)
prepends a space to the output when the date has a single digit.This will work: