Is this the worst date format ever?
Dec. 19th, 2017 09:23 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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.)
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.)
no subject
Date: 2017-12-19 12:04 pm (UTC)no subject
Date: 2017-12-19 01:43 pm (UTC)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.
no subject
Date: 2017-12-19 02:19 pm (UTC)no subject
Date: 2017-12-19 02:21 pm (UTC)no subject
Date: 2017-12-19 02:24 pm (UTC)That's a LONG time to put off getting off a shitty system.
no subject
Date: 2017-12-19 02:26 pm (UTC)There are always things to spend money on, getting to the top of the pile is the hard part.
no subject
Date: 2017-12-19 04:51 pm (UTC)no subject
Date: 2017-12-19 10:23 pm (UTC)no subject
Date: 2017-12-19 05:33 pm (UTC)no subject
Date: 2017-12-19 11:43 pm (UTC)> 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!
no subject
Date: 2017-12-22 11:34 am (UTC)>> 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
:)
no subject
Date: 2017-12-22 12:13 pm (UTC)(I'm fairly sure there's a Date Parse method that would be slightly simpler, but I had other things to do)
no subject
Date: 2017-12-22 07:47 pm (UTC)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.
no subject
Date: 2017-12-22 07:52 pm (UTC)no subject
Date: 2017-12-23 01:10 am (UTC)>> 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.