andrewducker: (Default)
[personal profile] andrewducker
I think I just found the worst date format ever.

CVS, in its "Entries" file stores the timestamp that the file was last changed, so that you can check if it has been updated.

The timestamp is formatted like this: "Mon Dec  7 14:59:26 2010"

Now, to a human that's a perfectly readable format. But if you want a computer to understand it you've got to separate it into its component parts which are _completely_ out of order.

ISO 8601 is the international standard. And following that, the format would be "2010-12-20T14:59:26Z". Which is slightly harder to read as a human (because it's all smooshed together), but so much easier to parse with a computer. And has the bonus that if you sort a bunch of dates using normal character order they'll come out correctly.

CVS gets a bit of an out for being created in 1986, 2 years before ISO 8601. But as ISO 3307 was available from 1975, there were standards they totally _could_ have used.

(I can't find details on what the ISO 3307 date-time format looked like, but ISO 2014 said to use YYYY-MM-DD, so I can only assume that ISO 3307 did something reasonably sensible.)

Next task for today: Write a parser for that date format.

(And look forward to a glorious future when I won't have to touch CVS any more.)

Date: 2017-12-19 12:04 pm (UTC)
jack: (Default)
From: [personal profile] jack
Ugh. There's got to be a "worst date" joke in here somewhere. And for that matter, there's surely something worse, where the dates are utterly ambiguous, or something, but probably not widely used.

Date: 2017-12-19 01:43 pm (UTC)
redbird: closeup of me drinking tea, in a friend's kitchen (Default)
From: [personal profile] redbird
My only thought here is something you're probably already thought of: you can throw away the "Mon" part as redundant before parsing the rest of it.

Edit after looking at Jack's comment: I suppose if a system was storing dates as "Mon 12/7 14:59:26 2010" (instead of "Dec 7") the "Mon" might be useful for determining whether that meant December 7th or July 12th. But that seems like an unlikely choice even for human readability.
Edited (adding a reply to someone else's comment) Date: 2017-12-19 01:46 pm (UTC)

Date: 2017-12-19 02:19 pm (UTC)
momentsmusicaux: (Default)
From: [personal profile] momentsmusicaux
You still have to use CVS?????

Date: 2017-12-19 02:24 pm (UTC)
momentsmusicaux: (Default)
From: [personal profile] momentsmusicaux
Git became mainstream about 10 years ago. SVN probably 15 years ago.

That's a LONG time to put off getting off a shitty system.

Date: 2017-12-19 04:51 pm (UTC)
ckd: (cpu)
From: [personal profile] ckd
ctime() format, ugh. You can't really blame CVS for anything except laziness, though, since it's a library function.

Date: 2017-12-19 10:23 pm (UTC)
ckd: (cpu)
From: [personal profile] ckd
Also, to parse it you can probably use the ancient and crappy strptime() which dates to the same era as ctime()/asctime() (surprised? didn't think so).

Date: 2017-12-19 05:33 pm (UTC)
From: [personal profile] j_v_lynch
We've been saying "Next release we're switching from CVS" for probably 4 years now.

Date: 2017-12-19 11:43 pm (UTC)
momentsmusicaux: (Default)
From: [personal profile] momentsmusicaux
Also:

> But if you want a computer to understand it you've got to separate it into its component parts which are _completely_ out of order.

Nope.

$ php -r "print strtotime('Mon Dec 7 14:59:26 2010');"
1292252366

Done!

Date: 2017-12-22 11:34 am (UTC)
birguslatro: Birgus Latro III icon (Default)
From: [personal profile] birguslatro
"Next task for today: Write a parser for that date format." ...

>> date: load "Mon Dec 7 14:59:26 2010"
== [Mon Dec 7 14:59:26 2010
]
>> foreach value date [print rejoin [type? value " " value]]
word Mon
word Dec
integer 7
time 14:59:26
integer 2010
>> date/4/hour
== 14
>> date/4/minute
== 59
>> date/4/second
== 26.0

:)

Date: 2017-12-22 07:47 pm (UTC)
birguslatro: Birgus Latro III icon (Default)
From: [personal profile] birguslatro
My example's in Rebol and your datestamp just happened to be correct Rebol code. So...

load datestamp

was all that was needed. It shows the advantage of having a rich set of datatypes coupled with whitespace separators. So, human readable and (near enough to) computer readable.

Date: 2017-12-23 01:10 am (UTC)
birguslatro: Birgus Latro III icon (Default)
From: [personal profile] birguslatro
No. In Rebol, time is a datatype, same as integers and strings and such are datatypes. Which allows you to do this kind of thing with them...

>> 10:3:17 + 3:2:1
== 13:05:18

Date is also a datatype, and your one would look like this: 7-Dec-2010/14:59:26

So...

>> date: 7-Dec-2010/14:59:26
== 7-Dec-2010/14:59:26
>> date/year
== 2010
>> date/month
== 12
>> date/weekday
== 2

Which suggests your Mon is wrong. Rebol's weekdays start at 1 for Monday.

June 2025

S M T W T F S
1 2 3 4 5 6 7
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 7th, 2025 11:26 am
Powered by Dreamwidth Studios