Potentially Useful

Writing boring posts is okay

ISO week

in: Programming

Every nerd knows that ISO 8601 is the “correct” way to display dates, but those who dig into the standard know that it encompasses more than YYYY-MM-DD format1. One of the stranger conformant formats uses week number; today’s date in this format is 2023-W31-3; i.e., today is the third day of the 31st week of 2023.

I’ve been using this format for note-taking for a couple years. I find it easier to track to-dos with this because it’s so easy to tell at a glance how many weeks and days I have to finish something.

In a POSIX command-line, you can print ISO-8601 week date with:

date +%G-W%V-%u

In Vim, use:

:put =strftime('%G-W%V-%u')

I’m not here to convince you to give up months or anything; there are plenty of confusing things about this format:

ISO and epi weeks

I worked with week numbers when I helped conduct research on Influenza-like illness. The CDC publishes a weekly surveillance report, and week 40 is traditionally recognized as the beginning of each flu season. The CDC also use week numbers to track other diseases, such as Covid-19.

Unfortunately, CDC weeks (aka “epidemiological weeks”, or “epi weeks”) aren’t ISO weeks; the former start on Sunday while the latter start on Monday, which means that Sundays will have different week numbers between the two systems. Except, more confusingly, when January 1 falls on a Thursday (as it will in 2026)—then only Sunday has the same week number, and the epi week will be one behind the ISO week for the other days. This table shows the ISO week and epi week of the first Monday of the year, ordered by the day that the year starts, and illustrates some of the issues with week-based dates.

January 1 First Monday ISO week Epi week
Monday January 1 1 1
Tuesday January 7 2 2
Wednesday January 6 2 2
Thursday January 5 2 1
Friday January 4 1 1
Saturday January 3 1 1
Sunday January 2 1 1

  1. Here’s a cool visualization of date and time formats. ↩︎