127

The other day at work I stumbled upon this bug and thought it was worth to write a blog post about. Spoiler: It has nothing to do with timezones!

TLDR: According to ISO standard 8601 (which is what Python's date.isocalendar().week uses for example), the first week of the year is the week with the first Thursday of the year. So sometimes the first few days of January belong to the last week of previous year, and sometimes the last few days of December belong to the first week of next year :D

you are viewing a single comment's thread
view the rest of the comments
[-] locuester@lemmy.zip 2 points 14 hours ago

I understand that. Because the months are zero indexed. But it’s not just the first month that’s “0-indexed”. The list of months is zero indexed. Perhaps I’m arguing semantics - but was simply adding clarity for the reader.

1st becomes 0, 2nd becomes 1, 3rd becomes 2

[-] sukhmel@programming.dev 1 points 12 hours ago

Yeah, but when days are 1-indexed and month are 0-indexed you just feel it's a very JavaScript thing to do

[-] locuester@lemmy.zip 2 points 7 hours ago

Yeah absolutely. I’m not disagreeing or saying it’s good.

I’m just correcting the strange wording.

this post was submitted on 24 Mar 2026
127 points (97.7% liked)

Programming

26232 readers
296 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS