3

Android took me to the year 42479

 3 years ago
source link: http://rachelbythebay.com/w/2012/07/22/date/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Android took me to the year 42479

I spotted another wonky date bug in a piece of software a couple of years ago. I was playing with one of the "holiday" Android phones, and was trying to take a picture with it to share with some people. The phone offered a whole bunch of options, but "post to Buzz" was not one of them. That told me the product was doomed, since you could Tweet it, post it to Facebook and a bunch of things like that, but not Buzz.

Anyway, while fighting with this beast of a device, I managed to make it show me info on the dates and times when my pictures had been taken. It claimed that one of my photos had been taken in the year 42479! This was a new one by me. I've seen a lot of crazy dates, but a five digit year was not something I had experienced previously.

After playing around with the numbers for a while, it dawned on me: someone was taking a time expressed as milliseconds since the epoch and was handing it to a function which expected seconds since the epoch. It was easy enough to prove, too. With GNU date, you can do this:

date -d @`echo $(date +%s)000`

Doing that right now gives you a year up around 44258. Be aware though, that due to the funky shifting of values, one second of real time is equal to about 16 minutes in bizarro world. In other words, by the time you read this, it'll probably be well past that point.

So that's advice for today: if you're working on something which generates dates for people to read, and they're five digit numbers north of 40,000, try taking a current time_t value and adding three zeroes to it. If it's the same thing, you probably have a disagreement in units somewhere.

This is just another one of those magic numbers I've picked up along the way. It's sort of like 497 days and Linux boxes. It's the sort of error you can count on seeing again.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK