Why no Zoned::iso_week()
or Zoned::iso_week_day()
?
#197
Replies: 1 comment 4 replies
-
This is a fascinating response! Thank you. I had no idea. Here in my part of the world (New England), ISO week dates are unheard of in every day life. I thought it was mostly used in finance applications or other bespoke systems. So this improves my understanding quite a bit, thank you.
OK, so yeah, this is almost 100% an API design question. I shipped the current API as a conservative posture. In part, because I didn't understand when or how often ISO week dates would be used and in part because there are some costs involved here. Methods like Here is what I propose:
This proposal does leave out I also still generally perceive the ISO week dates as at least a couple orders of magnitude (if not more) less common than the Gregorian calendar, so I'm not sure it's common enough to warrant proxying all of its methods (or even beefing up I think if What do you think? |
Beta Was this translation helpful? Give feedback.
-
Currently ISO-Week-Date related APIs are under
jiff::civil::iso_week_date::ISOWeekDate
.The first question is why there isn't direct
Zoned
based access to iso-week?The iso-week-date is changing with the Date Line, and hence it's bound to timezone. So my initial thought was that it must be located on
Zoned
. It's also confusing (to me) that Zoned haveyear()
,month()
andday()
,days_in_month()
,day_of_year()
, etc. functions, but noiso_week_year()
,iso_week()
oriso_week_day()
API-functions. This makes the API (to me at least) asymmetrical, and I was actually so confused about this, that I had to ripgrep it.So could there be an option to have iso_week APIs on Zoned? Or if this is not possible, some explanation could help to approach the API structure.
The second question on #196 was the usage of ISO week calendar in the first place:
The context here is Northern Europe (Finland and Scandinavia) and metric country (but also applicable pretty much to whole Europe). First day of week is Monday and the first week of the year is the week which have Thursday. So actually calendars are based on ISO-Weeks naturally by standardization.
On top of that, it's really common to refer weeks by their numbers in spoken and written communication: "I go on vacation on week 8" etc. Also all printed calendars have week numbers on the left column, and people enable week number views in Outlook. So (iso) week numbers are widely used, and pretty much every system should support them (if you like to do any "calendary" stuff).
The situation is different in other parts of world, but here it's very common, especially the iso-week numbers (2025-01-10 -> W2).
Beta Was this translation helpful? Give feedback.
All reactions