3

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 system date 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:

MvG
  • 382
  • 1
  • 6
  • 1
    Since I didn't sit on the POSIX Standards Committee I can't tell you with absolute certainty, but it appears that the Year was simply tacked onto the end of a Date/Time format that already existed. `%a %b %e %H:%M:%S` forms a perfectly good date/time combination, if it happens to be *this* year. – Robert Harvey Apr 22 '21 at 19:31
  • Whoever voted to close this as "opinion-based" hasn't understood what that means - obviously someone has made a decision about this in the past, this is an historical fact (maybe that decision itself was opinionated at that time, but that is not what that close reason is for). – Doc Brown May 07 '21 at 20:45

0 Answers0