I used to treat week numbers as a solved problem. Store a year and a week, render a planner, ship. Then a deadline labeled "week 1 of 2027" and a deadline labeled "the first week of January" landed on two ranges with no days in common.
The gap is ISO week numbering. It's the system Python's date.isocalendar() implements, the one Excel documents as System 2 / ISOWEEKNUM, and it does not follow the calendar year the way a lot of US-style WEEKNUM defaults do. If you plan work in week buckets, that difference shows up right at the year boundary.
What an ISO week actually is
The current standard is ISO 8601-1:2019 (confirmed in 2024; the full text is paywalled). I am relying here on two public restatements I opened today, which agree with each other:
- Microsoft's WEEKNUM help calls this System 2: "The week containing the first Thursday of the year is the first week of the year, and is numbered as week 1. This system is the methodology specified in ISO 8601."
return_type21 selects it.ISOWEEKNUMis the dedicated function for the same week number. - Python's
date.isocalendar()docs say an ISO year "consists of 52 or 53 full weeks," a week "starts on a Monday and ends on a Sunday," and "the first week of an ISO year is the first (Gregorian) calendar week of a year containing a Thursday."
Those two rules are equivalent, because an ISO week is always Monday–Sunday: the week that contains the first Thursday also contains January 4. ISO weekday numbers run Monday = 1 through Sunday = 7, which is not JavaScript's getDay() (Sunday = 0).
The 2026–2027 boundary, day by day
I checked the crossing with Python 3.13. The interesting dates are not January 1 alone:
from datetime import date
for d in (
date(2025, 12, 28), date(2025, 12, 29), date(2026, 1, 1), date(2026, 1, 4),
date(2026, 12, 28), date(2026, 12, 31), date(2027, 1, 1), date(2027, 1, 3),
date(2027, 1, 4), date(2027, 1, 10),
):
y, w, wd = d.isocalendar()
print(d.isoformat(), d.strftime("%A"), f"{y}-W{w:02d}-{wd}")
print("2026-W53-1", date.fromisocalendar(2026, 53, 1))
print("2026-W53-7", date.fromisocalendar(2026, 53, 7))
print("2027-W01-1", date.fromisocalendar(2027, 1, 1))
date.fromisocalendar(2027, 53, 1) # ValueError: Invalid week: 53
The output:
2025-12-28 Sunday 2025-W52-7
2025-12-29 Monday 2026-W01-1
2026-01-01 Thursday 2026-W01-4
2026-01-04 Sunday 2026-W01-7
2026-12-28 Monday 2026-W53-1
2026-12-31 Thursday 2026-W53-4
2027-01-01 Friday 2026-W53-5
2027-01-03 Sunday 2026-W53-7
2027-01-04 Monday 2027-W01-1
2027-01-10 Sunday 2027-W01-7
2026-W53-1 2026-12-28
2026-W53-7 2027-01-03
2027-W01-1 2027-01-04
Three things in that list surprise people:
- Monday, December 29, 2025 is already ISO week 1 of 2026. The ISO year started before New Year's Day.
- 2026 has a week 53. It runs Monday, December 28, 2026 through Sunday, January 3, 2027. Friday, January 1, 2027 is
2026-W53-5, not week 1 of 2027. - ISO week 1 of 2027 starts on Monday, January 4. And 2027 has no week 53:
date.fromisocalendar(2027, 53, 1)raisesValueError.
Nearby years that do have an ISO week 53 are 2015, 2020, 2026, and 2032. Week 53 is not a data-entry bug. Some years just have 53 ISO weeks.
The same function also matches examples published on the docs I used: Python's own 2004 walkthrough (2003-12-29 is 2004-W01-1, 2004-01-04 is 2004-W01-7), and Microsoft's ISOWEEKNUM example (2012-03-09 is ISO week 10, a Friday).
Two meanings of "week 1 of 2027"
Excel's default WEEKNUM is System 1: "The week containing January 1 is the first week of the year," and the default week begins on Sunday. I did not run Excel. Applying that documented rule to the calendar gives:
- System 1, week 1 of 2027: Sunday, December 27, 2026 through Saturday, January 2, 2027.
- ISO week 1 of 2027: Monday, January 4 through Sunday, January 10, 2027.
Those ranges do not overlap. January 3, 2027 is in System 1 week 2, and it is still ISO week 53 of 2026. If one team uses Python, ISO-8601 APIs, or ISOWEEKNUM / WEEKNUM(..., 21), and another uses default WEEKNUM, "ship in week 1" is two different weeks.
Even in 2026, where the ranges almost line up, they are not the same. System 1 week 1 of 2026 is December 28, 2025 through January 3, 2026. ISO week 1 of 2026 is December 29, 2025 through January 4, 2026. Each side has one day the other does not.
The YEAR() + ISOWEEKNUM() bug
A second trap is combining a calendar year with an ISO week number. For January 1, 2027, ISOWEEKNUM should return 53 (same week number as isocalendar()), and YEAR returns 2027. Stored together, that becomes the key (2027, 53). That key is invalid: 2027 has only 52 ISO weeks. The ISO year for that Friday is 2026.
The safer options I use:
- Store the ISO year and the ISO week together, not
calendar_year+iso_week. - Or skip week numbers as a primary key and store the Monday of the week as a date. You can always derive the week label for display.
def monday_of_iso_week(iso_year, week):
return date.fromisocalendar(iso_year, week, 1)
# "Week 53 of 2026" as a concrete range:
start = monday_of_iso_week(2026, 53) # 2026-12-28
end = date.fromisocalendar(2026, 53, 7) # 2027-01-03
If a ticket says "done in week 53," resolve it to those dates before you count business days inside the week. Counting "five business days in week 1 of 2027" only makes sense after you have agreed which Monday you mean.
A JavaScript version that stays in agreement with Python
Date still has no built-in ISO week number. This is the function I used. It treats the input as a date-only YYYY-MM-DD in UTC, so a local time zone cannot slide the calendar day. The ISO year is the year of that week's Thursday. Week 1 is the week that contains January 4 of that ISO year.
function isoWeek(isoDate) {
const [Y, M, D] = isoDate.split("-").map(Number);
const utc = new Date(Date.UTC(Y, M - 1, D));
const weekday = utc.getUTCDay() === 0 ? 7 : utc.getUTCDay(); // Mon=1...Sun=7
const thursday = new Date(utc);
thursday.setUTCDate(utc.getUTCDate() + (4 - weekday));
const isoYear = thursday.getUTCFullYear();
const jan4 = new Date(Date.UTC(isoYear, 0, 4));
const jan4Weekday = jan4.getUTCDay() === 0 ? 7 : jan4.getUTCDay();
const week1Monday = new Date(jan4);
week1Monday.setUTCDate(jan4.getUTCDate() - (jan4Weekday - 1));
const week = Math.round((thursday - week1Monday) / 86400000 / 7) + 1;
return { isoYear, week, weekday };
}
I compared it with Python's date.isocalendar() on 4,762 consecutive dates, from 2019-12-29 through 2033-01-10, in Node v24.22.1. Zero mismatches, including the 2004 and 2012 documentation examples and the 2020 / 2026 / 2032 week-53 boundaries.
What I now do with this
- If a plan is week-based, I write down the numbering system in the same place as the week number. "ISO 2027-W01" and "the calendar week that contains 2027-01-01" are different instructions.
- I never store
year=2027, week=53from a calendar date in January. I store the ISO year, or I store a Monday. - I don't special-case week 53 away. In 2026 it is a real, seven-day week that happens to straddle New Year's Day.
- When I need to count business days inside that week, I start from the Monday and Sunday I already resolved, then apply the weekend and holiday rules for that workplace. The week number itself does not know those rules.
If you want to see the actual calendar days in a span, I keep a small calculator at WorkdayMap that walks the dates and shows which ones were counted.
Sources
Fetched 2026-11-25 (Asia/Seoul):
- ISO 8601-1:2019 catalog page — current part of the standard (published 2019, confirmed 2024). Abstract only; full text not retrieved.
- ISO 8601 overview — general date-and-time format page; it does not itself define week 1.
-
Python 3
datetime.date.isocalendar()— ISO year / week / weekday rule and the 2004 example. -
Excel WEEKNUM — System 1 vs System 2 (ISO 8601),
return_type21. -
Excel ISOWEEKNUM —
ISOWEEKNUM("2012-03-09")documented as 10.
Date arithmetic in this post was run on 2026-11-25 (Asia/Seoul) with Python 3.13.5 and Node v24.22.1. I did not execute Excel; the System 1 ranges above follow Microsoft's documented rule applied to those calendar dates.
Top comments (0)