5 ms·
... with ISO8601 intervals you can express this as a string format, rather than using something ghastly like seconds or milliseconds: 'P6Y4M4DT3H45M15S' To
by ams6110 15y ago
... with ISO8601 intervals you can express this as a string format, rather than using something ghastly like seconds or milliseconds:
'P6Y4M4DT3H45M15S'
To me, that is absolutely no less "ghastly" as just saying the period is 3600 seconds (or whatever...)
- Keithamus 15y agoWell, 3600 seconds can be expressed much more simply than that: 'PT1H'. Which is more human readable than '3600'. The point in intervals is a compromise between human and machine readability - the point being that we can more easily determine long periods of time expressed in unit values rather than milli/microseconds.
- lloeki 15y ago> 'PT1H'. Which is more human readable than '3600' Not to mention six years, four months, four days, three hours, forty five minutes and fifteen seconds, which is nothing short of 200072715 seconds (which my brain definitely wants to parse as two billions and something).
- swombat 15y agoYeah, I was going to say that too... > The nice thing about ISO intervals is that they are human readable That P6 monstrosity is not human-readable. Not by 99.999% of humans, anyway.
- rmc 15y agoNonsense, it's very readible. You could tell someone who can't code to say "period" for "P", "hour" for "H", "time" for "T" etc. and they'd be able to read out the period exactly, accurately all the time. They would also know how write their own forms of this. Humans can also look at it and know, intuitavely, without a calculator how long it is. Trying to get them to multiple seconds (incl all the fun with leap seconds!) would be hard.
- tomelders 15y agoWhat is all this "Human Readable" nonsense. Who the hell is reading all these date times? If two pieces of software are passing dates around, use a UNIX, UTC timestamp. If a human wants to read it they're probably a programmer and know how to parse a timestamp. If they're not a programmer, then you shouldn't be showing them unformatted date times anyway.
- bad_user 15y ago(1) dates/times before 1970 cannot be represented using a Unix timestamp (2) you'll have much fun with leap seconds (3) a Unix timestamp is just a number represented as floating point ... not much different from all other numbers. A standard date representation on the other hand has a unique format that's distinguishable from all other data types. This comes in handy not only for humans reading it, but also for parsers of weak formats such as CSV Also data lives longer than both code or the documentation describing the data, this being the main argument for text-based protocols. (4) programmers are people with feelings too and would rather read human readable dates (since they are so common), rather than lookup the boilerplate for converting a Unix timestamp to a human readable format. Here's the Python version, which I know by heart just because I had to deal with a lot of timestamps: timestamp = time.time() # now datetime(*time.gmtime(timestamp)[:6]).strftime("%c") Oh wait, that gives me the date in UTC. Ok, that date is meant for me, the programmer that knows what he's doing, so here's how I can read it: datetime(*time.localtime(timestamp)[:6]).strftime("%c") Great, now I should write a blog post about it. Or you know, just use standard date formats that are human readable, because there's a reason why our forefathers used the dates representations that we use today, instead of counting scratches on wood or something ;-)
- ZenPsycho 15y agoTimes before 1970 can be stored as negative numbers.
- bad_user 15y agoTrue, but many libraries still do not know how to deal with negative timestamps. For instance PHP on Windows, prior to 5.1.0. MySQL's FROM_UNIXTIME was also not working last time I tried it. And many applications and scripts can break, like those that store and manipulate timestamps assuming a certain format (e.g. positive integers). The Unix timestamp was created to deal with timestamps, not with date representations. Therefore this requirement (dates prior to 1970) was not an issue that had to be dealt with explicitly.