Strftime's %C and %y formats versus wide-ranging tm_year values

Paul Eggert eggert at CS.UCLA.EDU
Wed Sep 22 18:14:25 UTC 2004


"Olson, Arthur David (NIH/NCI)" <olsona at dc37a.nci.nih.gov> writes:

> 	4. Using the format "%C%y" produces the year in all cases (with
> leading zeroes in some cases).

That is a very nice property, one I hadn't seen or thought of before.
Good work!  I can't think of any way to improve on that approach.

> tm_year         %C      %y
> ...
> 0               00      00
> -1              -0      01
> ...
> -100            -1      00
> ...
> -1000           -10     00

One very small point: tm_year is actually the year minus 1900, so the
header for column 1 should be "Gregorian year" or just plain "year".



More information about the tz mailing list