ISO 8601 Dates and Weeks

  • Date: YYYY-MM-DD (e.g. 2026-08-12)
  • Week: YYYY-Www-D (e.g. 2026-W33-3)
    • the year here is the ISO week-numbering year, which can differ from the calendar year near Jan 1 / Dec 31
    • D is weekday (1 = Mon … 7 Sun)

Why ISO weeks?

  • Standardized way to define weeks.
  • No partial weeks.

ISO 8601 rules:

  • Weeks start on Monday.
  • Week 1 of a year is the week containing that year’s first Thursday (equivalently: the week containing Jan 4).
  • So the first few days of January can belong to the last week of the previous ISO year, and the last few days of December can belong to week 1 of the next ISO year.
  • %G (ISO week-numbering year) exists separately from %Y (plain calendar year)
  • Every ISO year has either 52 or 53 full weeks (a “leap week”)

Business cases, but I find leap weeks interesting; on the Digital Hall most dates will show the ISO week if hovered over

Cf. Shire Calendar in The Lord of the Rings

GNU date command

  • date +%Y-%m-%d or date -I: today’s ISO date
  • date -d "STRING" +%Y-%m-%d — parse arbitrary date string (“next friday”, “3 days ago”, “August 12, 2026”) to ISO date
  • date +%G-W%V-%u: (use %G, not %Y)

Shell wrappers

Fish

Autoloaded, one function per file, in ~/.config/fish/functions/:

isodate.fish:

function isodate --description 'Convert a date string to ISO 8601 date'
    date -d "$argv" +%Y-%m-%d
end

isoweek.fish:

function isoweek --description 'Convert a date string to ISO week date'
    date -d "$argv" +%G-W%V-%u
end

Bash / Zsh

Drop into .bashrc / .zshrc, or a sourced file:

isodate() {
    date -d "$*" +%Y-%m-%d
}
 
isoweek() {
    date -d "$*" +%G-W%V
}

"$*" joins all args into one space-separated string, so isodate next friday works without quoting.

References

Wikipedia ISO Week date