Last year, the first working day after Christmas was 29 December 2020. I began the day by merging a pull request. Automated tests checked the code cha

How we fixed a strange ‘week year’ bug

submited by
Style Pass
2024-12-31 14:00:04

Last year, the first working day after Christmas was 29 December 2020. I began the day by merging a pull request. Automated tests checked the code change did not break anything, but to my surprise one of the tests failed.

The test creates a new API key and makes a couple of checks on it. It failed because the creation date displayed for the API key was a year later than the actual date. It should have been 2020 but it was 2021.

I created a new API key myself and looked at its creation date. It was a year ahead. The test had identified a real bug in our live application.

We were in the last few days of the year and the application already thought it was next year. This sounded familiar. I remembered a similar bug where Twitter thought it was already 2015 at the end of 2014 .

Many programming languages support formatting patterns for dates and times. For example, yyyy-MM-dd HH:mm:ss might produce 2020-12-29 10:00:00.

Leave a Comment