December 30, 2019

TIL: y is not Y is not year, like you'd think

unicode date format patterns are a little more nuanced than the “standard” strftime() supported formats.

note the difference between the following:

man strftime (linux)

       %y     The year as a decimal number without a century (range 00 to 99).  (Calculated from tm_year)
       %Y     The year as a decimal number including the century.  (Calculated from tm_year)

man strftime (osx)

     %Y    is replaced by the year with century as a decimal number.
     %y    is replaced by the year without century as a decimal number (00-99).

and the meaning of y and Y in unicode

where Y - Year (in “Week of Year” based calendars). This year designation is used in ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. May not always be the same value as calendar year.”

turns out that when you’re dealing with a unicode formatting system (and this might not always be obvious) you really need to pay attention to the difference between y and Y.

Creative Commons License