I’m beginning to think that
Julian Ordinal dates are my arch-enemy. I have to wonder how the conversation went when someone first thought them up?
|Bob:||I think I’ll scrimp a few bytes by converting all of the dates in my database to integers.|
|Alice:||We can make that work if we store the number of days since an epoch. When would you like your epoch to start? Maybe Jan 1, 1900? We can get almost 180 years in 2 bytes.|
|Bob:||No! I’ve got a better idea! We’ll store the number of days into the year in the rightmost 3 digits, then the number of years since 1900 in the leftmost 3 digits. Like 109072.|
|Alice:||wtf? Sweet Baby Obama, why would you do that?|
|Bob:||Year math is easy! Just add the number of years * 1000! I’m a genius!|
|Alice:||Wait, that doesn’t work for leap years.|
|Bob:||Sure it does: 108001 + 1000 = 109001. Jan 1 2009 is one year after Jan 1 2008, see?|
|Alice:||Yes, but 108060 is Feb 29, while 109060 is Mar 1. So that’s even worse, as it looks like it works but it really doesn’t.|
|Bob:||I don’t care, as both are the 60th day of the year and that’s all that matters.|
|Alice:||And … ?|
|Bob:||We’re a shipping company, so that makes more sense.|
|Alice:||We don’t ship 24/7, so the number of days into the calendar year is irrelevant.|
|Bob:||It’s still easier to do day math: if you want a week ago, just subtract 7.|
|Alice:||Yeah, but 7 days before Jan 1 isn’t 001 – 7 = 994. And 7 days after Dec 31 isn’t 365 + 7 = 372. That’s just ridiculous.|
|Bob:||But you can see the year! In the number!|
|Alice:||And instead of 2 bytes, you’re back up to at least 3 .. but probably 4. What have you gained?|
|Bob:||You’re a patootiehead!|
Please, someone, enlighten me on exactly what
Julian Ordinal dates are good for.
Update: Thanks to PaulH for correcting my misnomer.