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

Allow for varying first week of the year #31

Open
ffinger opened this issue Mar 11, 2020 · 3 comments
Open

Allow for varying first week of the year #31

ffinger opened this issue Mar 11, 2020 · 3 comments

Comments

@ffinger
Copy link

ffinger commented Mar 11, 2020

This package conveniently handles week to date and date to week conversions with varying definitions of the first day in each week.

In epidemiology we are also confronted with varying definitions of week 1 in a year. The ISO norm says: "week 01 is the week with the Gregorian year's first Thursday in it", the week before being week 52 or 53 of the previous year.
https://en.wikipedia.org/wiki/ISO_week_date#First_week

There is however situations in which week 1 is defined as the week containing 1st January, which is not always the same as above. Other definitions are also possible, e.g. the week containing the first Monday, Tuesday, ... Sunday of a year.

It would be great to add an option to choose which of these definitions should be used, with a default to the definition used by ISO.

@ffinger
Copy link
Author

ffinger commented Mar 11, 2020

@zkamvar
Copy link
Member

zkamvar commented Mar 11, 2020

Hi @ffinger,

Thank you for pointing this out. The way {aweek} works is that it looks for the first week that contains at least four days of the new year, otherwise, it is the last week of the previous year.

I'm afraid that I do not have much time to implement an alternative definition at the moment (I'm currently moving jobs and do this voluntarily now). Can you point me to some documentation that defines these different week definitions?

@ffinger
Copy link
Author

ffinger commented Mar 11, 2020

Hi @zkamvar,

yes, I am aware that you do this voluntarily now, I mainly wanted to document the issue and start a discussion about the possible solutions. All the better if you have time to start implement things, but feel free to say no.

The isoweek definition (week 1 is the week of the first Thursday in a year) is equivalent to yours (first week that contains 4 days of the new year. For the CDC epiweek it's the same.

The other definitions I was talking about are unfortunately not standardized and depend on the country, the implementing agency or even the dataset. This is why I would go with a fully flexible framework if possible, keeping the current definition as the standard.

I would suggest to implement two alternative ways of defining the first week:

  • choosing the first weekday (first Monday, first Tuesday, ... Sunday) of the new year defines the first week, keeping Thursday as the default
  • choosing the date that the defines the first week (usually it will be Jan 1st, but could be any date in theory)

What do you think?

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