-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Week number of the Year #102
Comments
Probably, but it depends on what you mean by 'week number of the year'. See https://www.wikiwand.com/en/ISO_week_date |
Oh wow, it seems there can be multiple elements affecting what the week date is. Depending if the start of the week is set Monday or Sunday, and if the week day is containing vs ISO. I honestly cannot think of an easy way to get a any of the possible "valid" week dates 😅. Judging by the amount of code/config from date-fns/moment that have the most complete set (Locale Week Date, full config and ISO Week Date) it doesn't seem trivial. Thank you so much for the read, if you already know of any quick way to get a week date I'd be amazed to know, but apart from that please feel free to close this issue as I assume it is out of scope for this library. |
An extremely rough estimate would be something like:
604800000 being the length of a week in milliseconds... but I don't know if that's at all suitable for what you're trying to do. 😄 I think it would be reasonable to add some more stuff to this library, including a function (or more likely multiple functions that allow choice of which variety of week number is wanted) to do this kind of operation, but without making it fully TZ and locale aware. Maybe... it's perhaps not that useful without TZ being taken into account. I was very reluctant to do a TZ/locale aware library originally due to the maintenance burden that would come with, but I think there is room for it now - browsers have the |
Thank you so much for the example 🙏! Haha I typed all of those reasons and then deleted it to be brief 🤣 It seems clear the goal is to have a pure/agnostic/basic date/datetime/duration/time library to work with PS from the get go. And it seems like TZ-unaware week date might be not very usable as the result might be significant on the edges. My intent is to display a calendar UI as Google Calendar, no calculations so far for the weeks, so precision is not crucial atm, but precisely should be something configurable/localised. The lib also seems too beautiful and "core" for such functions, agree a separate lib might be better. For the time being I'm gonna FFI date-fns, it really seems tricky to get a full solution right in PS way for my skill level atm 😅 |
At work, I implemented a generator based on this code, so that we have the |
Hi, thank you for such a great lib.
I'm trying to figure out a way to get the week of the year.
Is there a way to accomplish this with the library?
The text was updated successfully, but these errors were encountered: