Happy Leap Week!

So leap weeks are a thing. In the ISO week date system “week 1” is “the week with the year’s first Thursday in it”. Today, Monday Dec 29 2014, is actually ISO week 1 for the year 2015. How’s that for confusing?

Rumor has it this weird calendar math is responsible for Android Twitter being broken. Some part of Twitter’s servers were returning a date a year in the future, in the year 2015, which is causing invalid OAuth signatures because of an expired certificate or something like that. Presumably the engineer used the ISO week-year by accident.

This is a bug that keeps on giving; two years ago iPhones got stuck in Do Not Disturb mode, probably for the same bug.

In Java SimpleDateFormat the difference is whether you ask for “yyyy” or “YYYY” and the docs don’t make it obvious you really want “yyyy” unless you’re doing something weird.

In Unix date’s format language (strftime?) the weird year to avoid is %G. %Y does what’s expected.

$ date -u
Mon Dec 29 15:47:54 UTC 2014
$ date -u +'%G-W%V-%u'
2015-W01-1