Reputation: 63
An IMAP server is sending me timestamps that look like this:
Tue Apr 12 2016 09:45:14 GMT-0500 (CDT)
I've seen this format enough times in enough places to make me think it's standardized. But I don't know what the name of the standard would be.
It's very similar to the RFC 5322 datetime format for emails (my first guess, since I'm working with an IMAP server), but not quite.
Does anyone recognize it?
Edit: Apparently this is the standard format for JavaScript's Date.prototype.toString() as well, according to MDN. The fact that I'm seeing in multiple places in unrelated contexts (JS/IMAP) makes me think it must be some sort of standard. Still can't find a name for it.
Upvotes: 2
Views: 1415
Reputation: 796
Unlike most SO answers, this is an admission of failure. Originally I thought this was the C library function asctime() - C casting its very long shadow over UNIX and hence the Internet. But as the OP pointed out, that would generate something of the form Tue Apr 12 09:45:14 2016
and not Tue Apr 12 2016 09:45:14 GMT-0500 (CDT)
. I should have stopped looking at this point, but curiosity pushed me on.
After much trawling, I believe that the format is not a standard but a bastardization of asctime and RFCs 822 and its descendants.
asctime
(and cousins, e.g. ctime
, strftime
) gets you Tue Apr 12 09:45:14 2016
, so the year is in the 'wrong' place and there is no offset or zone. I suspect this latter bit is environmental, affected by LC_TIME
. The source code for GNU date appears to agree.See GNU date in the coreutils pkg source Tues, 06 Apr 16 09:45:14 CDT
.
RFC 2822's effort would be Tues, 06 Apr 2016 09:45:14 -0500
, fixing the Y2K issue and being clearer on the offset from universal time. RFC 5322 is the same. And (aargh) introducing a comma after the day of week. See RFC 822, etc.Tue, 06 Apr 2016 09:45:14 GMT
using things like the RFC1123 formatter At this point I realized the irony of wasting so much time learning about time, and the double irony of knowing before I even started that time in computer programming is one of the most notoriously mis-understood and inconsistent areas of all and I should know better than to get sucked in. Let that be a lesson to you all. Flee, my friends, flee!
Upvotes: 3