|
Source: (consider it)
|
Thread: Happy 20100102!
|
ken
Ship's Roundhead
# 2460
|
Posted
If you were the sort of person that keeps a library of Perl code to change dates from one text format to another you would know that there is a wonderful standard text representation of dates that is trivially sortable. YYYYMMDD And if you were a programmer you would use it when writing programs because it makes life easier. Its called ISO8601 and its probably the only such international standard that adopts the traditional Chinese way of doing things and it works and it makes my life easier and Marcus Kuhn describes it here
And today, its a palindrome!
20100102
![[Yipee]](graemlins/spin.gif) [ 02. January 2010, 16:28: Message edited by: ken ]
-------------------- Ken
L’amor che move il sole e l’altre stelle.
Posts: 38281 | From: London | Registered: Mar 2002
| IP: Logged
|
|
Ariston
Insane Unicorn
# 10894
|
Posted
It's also a palindrome if you live in the States: 01022010
Everyone else, though, gets to sit on their hands and wait for another month for their Palendrophic Phun.
-------------------- If I can't find a friendship problem, I'll MAKE a friendship problem!
Posts: 4888 | From: College Park/Brookland | Registered: Jan 2006
| IP: Logged
|
|
PeteC
 Loyaute me lie
# 10422
|
Posted
Is this another trainspotters' thread ?
Posts: 18051 | Registered: Sep 2005
| IP: Logged
|
|
Amorya
 Ship's tame galoot
# 2652
|
Posted
quote: Originally posted by ken: And if you were a programmer you would use it when writing programs because it makes life easier.
Lies! The only date format worth anything is the number of seconds since 1st Jan 1970.
Posts: 2206 | From: Coventry | Registered: Apr 2002
| IP: Logged
|
|
|
|
Campbellite
 Ut unum sint
# 1202
|
Posted
According to Microsoft, that was the date of the creation of the universe.
-------------------- I upped mine. Up yours. Suffering for Jesus since 1966. WTFWED? In memoriam: jlg
Posts: 11934 | From: between keyboard and chair | Registered: Aug 2001
| IP: Logged
|
|
HCH
Shipmate
# 14313
|
Posted
I can assure you that plenty of programmers in the U.S. also use dates in the 8-digit YYYYMMDD format. As Ken noted, it is easy to compare such dates simply as numbers.
Posts: 853 | From: Illinois, USA | Registered: Nov 2008
| IP: Logged
|
|
Amorya
 Ship's tame galoot
# 2652
|
Posted
quote: Originally posted by Zappa: Why?
It's known as the UNIX timestamp. At a precision of one second, it's the best way of storing as much information as possible about a time/date in a certain amount of computer memory.
In 4 bytes (32 bits) of memory, with this method of storing dates, you can represent any second between the years 1901 and 2038. (You can have negative numbers in it, which is how it manages things that are before 1970!)
You might be thinking, what happens in 2038? Well, remember the millennium bug? That's where some computer systems (ones that didn't use the UNIX timestamp format) stored years as two digits, and couldn't distinguish between 1900 and 2000. In the year 2038, the same thing happens to any computer that stores a UNIX timestamp in 4 bytes of memory. It can't deal with a time beyond 03:14:08 UTC, 19 January 2038. The date would reset back to 1901.
The solution to that is to move to using 8 bytes of memory (i.e. 64 bits). That lets us store dates for millions of years to come.
So why is this so much better than storing times the other way (as year-month-day hours:minutes:seconds)? There's two reasons. Firstly, the UNIX timestamp is just a number. Storing a number is easy: we already know how to do that. But for the other format (which is defined as ISO 8601), it isn't immediately obvious how to store it. Do you store it as text characters? In that case it takes 14 bytes. Do you store each part separately as a number (the year then the month then the day etc)? In that case it takes 7 bytes. Or if you squash all the bits together (rather than keeping each part as a separate set of bytes) it'd take 5 bytes. When people were making decisions about what formats to use, they noted that 4 bytes (for the UNIX timestamp) was less than the 5 bytes minimum for the ISO 8601 format.
The second reason is, this way is easier to work with inside a computer: to add a minute to a time, just add 60 to its number. The only time you get into complicated logic about how many days in a month is when you're presenting data to a human. Anything the computer stores for its own use doesn't need that logic to be applied.
Because of the Year 2038 problem, UNIX timestamps tend to be moving to use 8 bytes for storage. Does that mean that ISO 8601 is more efficient after all? Well, unlike when these formats were invented, these days computers have memory to spare, so saving only a few bytes doesn't matter so much. Also, it's easier in general to make the number of bytes used be a power of two: when storing things in the ISO format, most of the time they'd take 8 bytes anyway, since 8 is the next highest power of two after 5. Thus the amount of space taken up would be the same.
Amorya
ETA: Bet you wished you hadn't asked! [ 02. January 2010, 20:42: Message edited by: Amorya ]
Posts: 2206 | From: Coventry | Registered: Apr 2002
| IP: Logged
|
|
Amorya
 Ship's tame galoot
# 2652
|
Posted
You may have sussed that I'm a bit of a calendar geek as well as a software geek.
Check out this blog post, which attempts to succinctly explain the history of our calendar in order to answer the question "How frequent is a blue moon?". From this I learnt that my computer is quite capable of giving me a calendar of October 1582, which is more than I expected of it. Sadly, my phone isn't quite as clever: it avoids the problem by assuming the whole of 1582 doesn't exist!
Amorya
Posts: 2206 | From: Coventry | Registered: Apr 2002
| IP: Logged
|
|
HCH
Shipmate
# 14313
|
Posted
Although this may be getting far afield, I will add:
Among the advantages of the 8-digit YYYYMMDD format for storing dates are that it avoids the "Year 2000" question, it should be able to handle dates for almost 8000 more years, it is easy to convert into separate year, month and day, and (if stored as 8 characters) it is human-readable. It is used almost everywhere in the business world's programming. One disadvantage is that it is tied to a specific calendar.
People store dates in many formats. For instance, it is common to count days since the advent of the Gregorian calendar. (There is a glitch in this, as the calendar was not adopted by all countries at the same time.) Astronomers sometimes count days with a starting point some thousands of years ago. There are many calendars in use, and no reason to expect universal adoption of any of them any time soon.
Posts: 853 | From: Illinois, USA | Registered: Nov 2008
| IP: Logged
|
|
Amorya
 Ship's tame galoot
# 2652
|
Posted
Luckily there are plenty of APIs out there that do all the hard work, so you don't have to!
I'm currently writing an iPhone app, that will be localised to English (UK), English (US) and Welsh. In doing this, I discovered that the dates are the only bit of the iPhone OS currently translated into Welsh. Tell it you're in Wales, and nothing changes except you now get Dydd Sadwrn, Ionawr 02 on your homescreen. Quite impressive attention to detail, you might think, since I hadn't expected any Welsh support at all. But even better, they've got Manx and Cornish in there too!
Anyhow, the upshot is I don't have to worry about how the date is stored, or even if the different regions use different calendars. The programmers who designed the thing offered me a way of retrieving a date entered by the user (in their native format), storing it, and pulling it out and displaying it in whatever format I want.
Amorya
Posts: 2206 | From: Coventry | Registered: Apr 2002
| IP: Logged
|
|
PeteC
 Loyaute me lie
# 10422
|
Posted
I was right! It is a trainspotters' thread
I just read it and I understood A... the...
Posts: 18051 | Registered: Sep 2005
| IP: Logged
|
|
Amorya
 Ship's tame galoot
# 2652
|
Posted
quote: Originally posted by PeteC: I was right! It is a trainspotters' thread
Posts: 2206 | From: Coventry | Registered: Apr 2002
| IP: Logged
|
|
|
|
Lynn MagdalenCollege
Shipmate
# 10651
|
Posted
I could point out that Tim Powers uses palindromes often in his novels & sees a certain power in them. For instance, in Expiration Date, palindromes act as snares for 'ghosts' (which, in the Powers realm, are not the soul/spirit of the human being but something more like a snapshot - one can "throw off ghosts" in times of trauma, for instance the birth trauma and --wait for it-- the death trauma).
Thus in the novel one finds many ashtrays inscribed LA CIGAR TOO TRAGICAL because the hovering ghost, trying to figure out what the palindrome means, is then qucikly burned up by a match or a cigarette. Which, in the Powers scheme of things, is a better outcome than being consumed by another human who has learned to savor the essence of ghosts. ![[Paranoid]](graemlins/paranoid.gif)
-------------------- Erin & Friend; Been there, done that; Ruth musical
Posts: 6263 | From: California | Registered: Nov 2005
| IP: Logged
|
|
|