In standard POSIX locale strftime(buf, size, "%c", time)
will format the date and time in an order that has confused me a number of times because it has month and day precede the time, but year follow at the end. Example (from ccpreference): Sun Oct 17 04:41:13 2010
.
Since this appears to be a POSIX specification, the most canonical documentation I could find is this from https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html:
In the C or POSIX locale, […] the replacement strings for the following specifiers are:
⋮
%c
Equivalent to%a %b %e %T %Y
.
I find this highly confusing, because putting the time between different parts of the date feels counter-intuitive to me (with a background in modern European conventions).
Some ANSI C draft referenced on Wikipedia suggests that
strftime
provides a way of formatting the date and time in the appropriate locale- specific fashion, using the%c
,%x
, and%X
format specifiers. […] The facility is based on the UNIX systemdate
command.
So apparently that is the next step back into history, even though the exact order of fields for default locale isn't specified in that document.
But why does the UNIX date
binary do things that way?
Where did this come from?
How far back can this be traced?
Does this reflect everyday usage at the time and place, or was there a more technical reason for this format?
Some negative results:
- https://en.wikipedia.org/wiki/Date_and_time_notation_in_the_United_States discusses date and time in isolation but not in combination.
- https://en.wikipedia.org/wiki/Date_and_time_representation_by_country has only high-level overview, and only discusses date and time individually but not their combination.
- I looked at Unicode CLDR v39 data but couldn't find any mention of such patterns. None of the XML files contain text that matches the regular expression
(hh|HH|KK|kk):mm.*yy
which is what I'd expect the time-then-year format to contain. The data again appears to describe date and time in isolation, not combination. - The C Programming Language by K&R 1st edition doesn't mention
strftime
yet. - The
date
item in https://en.wikipedia.org/wiki/List_of_Unix_commands links to https://en.wikipedia.org/wiki/Unix_time which has plenty of history for the binary representation but no content for the command line tool any more. As far as I can tell from history, there used to be a one-paragraph section on the command line tool with no historic background but that section got deleted.