this post was submitted on 24 Mar 2026
94 points (99.0% liked)
Programming
26225 readers
535 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
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Even better: two weeks with the same week number can exist in the same year.
How is that? Do you mean that week 1 can occur twice? Or is there another issue?
IIUC you can have days at the start and the end of the year that are all in week 1, and those are two different weeks. But one of those would be, let's say, week 1 year 2025, and the other would be week 1 year 2026. According to the blog post if you have a week 1 at the end of a year the ISO year number for that week is the next year.
It only happens with ISO weeks. An example is 2006. Each of the weeks belong to different years (so 2005W52 and 2006W52 are different), but each can contain days from another year. So for example Sunday 2006-01-01 is part of week 52 of 2005. Week 1 starts on January 2. Then at the end of 2006 you have another week 52, but that week is actually part of 2006.
It's a bit of a cheeky thing to point out, because at no point is a day in two different weeks, and the week itself only belongs to one year. It's just that you can't assume that any given day belongs to the same year as the week it is in. That is: 2006-01-01 is in 2005W52 not 2006W01.
This is basically the takeaway from my blog post, if you're going to use weeks, use the ISO year instead of the calendar year :)
Fuck, I just wrote an app to help HR process data and I had to, without using Ai, define the first week of the year to match that ISO spec. Week 53 was a fun one but I now have to cover two weeks with the same number.
Yep, but the year of week will be different for each.
Use a date library. Life is too short to make your own. The new Temporal library in JavaScript is quite good.
Sadly, Safari fucks us yet again.
It's written in C++ lol