Skip to content
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 Numbering #32

Open
mbarkhau opened this issue Aug 30, 2020 · 4 comments
Open

Week Numbering #32

mbarkhau opened this issue Aug 30, 2020 · 4 comments

Comments

@mbarkhau
Copy link

mbarkhau commented Aug 30, 2020

This relates to PR #31

Looking into this further, it appears that (at least for python) strftime actually goes from 0-52 and not 1-53 and the weeks are not actually always 7 days long:

import datetime as dt

base_date = dt.date(2020, 12, 26)

for i in range(10):
    d = base_date + dt.timedelta(days=i)
    print(d.strftime("%Y-%m-%d  %a  %%W:%W  %%U:%U  %%G-w%%V: %G-w%V"))
2020-12-26  Sat  %W:51  %U:51  %G-w%V: 2020-w52
2020-12-27  Sun  %W:51  %U:52  %G-w%V: 2020-w52
2020-12-28  Mon  %W:52  %U:52  %G-w%V: 2020-w53
2020-12-29  Tue  %W:52  %U:52  %G-w%V: 2020-w53
2020-12-30  Wed  %W:52  %U:52  %G-w%V: 2020-w53
2020-12-31  Thu  %W:52  %U:52  %G-w%V: 2020-w53
2021-01-01  Fri  %W:00  %U:00  %G-w%V: 2020-w53
2021-01-02  Sat  %W:00  %U:00  %G-w%V: 2020-w53
2021-01-03  Sun  %W:00  %U:01  %G-w%V: 2020-w53
2021-01-04  Mon  %W:01  %U:01  %G-w%V: 2021-w01

This has the benefit of avoiding the third issue I mentioned in the PR.

Even with the current ambiguity of WW/0W, they have an impact on
how to interpret the YYYY/YY/0Y which is not explicitly stated.

@mbarkhau
Copy link
Author

mbarkhau commented Aug 30, 2020

Looking back at the part description:

  • WW - Short week (since start of year) - 1, 2, 33, 52
  • 0W - Zero-padded week - 01, 02, 33, 52

I don't think these can actually correspond to any of the four week numbering schemes I mentioned in the PR as those use either the range [0-52] or [1-53], but none of them use the range [1-52].

@mbarkhau
Copy link
Author

Personally I think all this is tedious and I would advise people to not use such numbers, but if they must then these are the definitions I would suggest:

  • WW - Short week (Mondays since start of year) - 0, 1, 2, 33, 52 - (corresponds to strftime("%W"))
  • 0W - Zero-padded week - 00, 01, 02, 33, 52
  • UU - Short week (Sundays since start of year) - 0, 1, 2, 33, 52 (corresponds to strftime("%U"))
  • 0U - Zero-padded week - 00, 01, 02, 33, 52

The above can be used together with the normal YYYY/YY/0Y but if ISO 8601 week numbers are used, then they should only be used in conjunction with GGGG/GG/0G.

  • GGGG - ISO 8601 week-based year (corresponds to strftime("%G"))
  • GG - Short ISO 8601 week-based year
  • 0G - Zero-padded ISO 8601 week-based year
  • VV - Short ISO 8601 week - 1, 2, 33, 53 (corresponds to strftime("%V"))
  • 0V - Zero-padded week - 1, 2, 33, 53

See also:

@mahmoud
Copy link
Owner

mahmoud commented Sep 2, 2020

I agree it's a bit tedious. I consider CalVer more descriptive than an enforceable standard. Note the note in that section which specifies that projects claiming to be CalVer need to state any unconventional calendar choices. (Still waiting for the day I do a Jalali CalVer project).

I'm not even sure using ISO as the default helps:

Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.

Hardly intuitive, that seems like that's going to need explanation for most audiences regardless.

So I'm not sure if all the notation is necessary. We always have the option of letting the maintainer specify what's meant by "week". They know their audience best.

We can add a note that says week segments should be used with caution, because there are so many definitions, but when in use the range won't exceed 00-54, and that it's up to maintainers to specify the semantics further.

@mbarkhau
Copy link
Author

mbarkhau commented Sep 2, 2020

Oh wow, I didn't know about 54 week years. So much fun!

Rather than go back and forth on PR #31, should I close and let you (re)write yourself.

Since PyCalVer will be generate week numbers, I'll have to decide on some definition. I think I'll go forward with the above parts, since they're easy to implement with strftime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants