dashbitco / nimble_strftime

A simple and fast strftime-based datetime formatter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

%u is zero padded

wojtekmach opened this issue · comments

Per documentation we have:

u | Day of the week | 01 (monday), 07 (sunday)

However on Linux [1] we have:

%u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. (Calculated from tm_wday.) (SU)

and on FreeBSD we have [2]:

%u is replaced by the weekday (Monday as the first day of the week) as a decimal number (1-7).

I wonder if there was a specific reason for 0-padding? If not, happy to change it.

[1] http://man7.org/linux/man-pages/man3/strftime.3.html

[2] https://www.freebsd.org/cgi/man.cgi?query=strftime&sektion=3

I also found a link to 2018 edition of POSIX [1] that is also not zero padded.

I believe we don't say anywhere that we follow any particular strftime spec, so perhaps worth saying we follow the POSIX one (and fixing any discrepancies along the way)?

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html

I wonder if we should drop padding completely for that modifier or still allow it: e.g. %2u would return 01 and such. How does that sound 2 u?