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

Add support for WEEK period #966

Open
16 of 32 tasks
nikhilwoodruff opened this issue Dec 22, 2020 · 3 comments · May be fixed by #1146
Open
16 of 32 tasks

Add support for WEEK period #966

nikhilwoodruff opened this issue Dec 22, 2020 · 3 comments · May be fixed by #1146
Assignees
Labels
kind:feat A feature request, a feature deprecation kind:roadmap A group of issues, constituting a delivery roadmap

Comments

@nikhilwoodruff
Copy link
Contributor

nikhilwoodruff commented Dec 22, 2020

Hi there!

Firstly, thanks to the OpenFisca community for enabling us to use such a neat framework. In developing OpenFisca-UK, many variables including the majority of state benefits are specified in weekly amounts, which would be ideal to use as a standard period. I'm aware this has been discussed previously in #670 and #763.

As I understand it the main problems are identified in this comment:

About weeks, this is going to bring tricky questions about relationship between periods.

Right now, OpenFisca period model relies on the assumption that period fit well together. A YEAR is composed a 12 MONTHs . We could relatively easily add DAY, as a month is composed of 28 to 31 DAYs. We actually used to support them, but deprecated it as no one was using it.

However, WEEK is more challenging: they don't fit well in a month, nor in a year. And question will arise:

  • If A's definition period is the week, can I calculate A for a year?
  • If so, what do I do with the weeks that are only partially included in the year?
  • Can we have a generic answer to the previous question, or is it going to be country-specific?

OpenFisca-UK has been relying off an implementation of the WEEK period in this fork, but it'd be good to see if this is something that can benefit other country packages. In our implementation, we answered the above questions with:

  • If A's definition period is the week, can I calculate A for a year?

Yes.

  • If so, what do I do with the weeks that are only partially included in the year?

Include the week of the first day of the year, and add weeks until we have reached (DAYS_IN_YEAR // 7) weeks. This also applies to months, respectively.

  • Can we have a generic answer to the previous question, or is it going to be country-specific?

Use Monday as the first day of the week (this might be different in other countries)

However, one problem that the WEEK introduces that I can't think of a way around is that it wouldn't be entirely in line with other periods. In the documentation each period has a unique string to specify e.g. the month of 05-01-2021 ("2021-01"), and a month from 05-01-2021 ("month:2021-01-05"). The WEEK period would be ambiguous with DAY due to the datetime format, so we'd only be able to specify the week from the week start, but this doesn't actually prevent any features, as we would just need to start from the first day of the week.

Hopefully this has added something to the discussion - I know this feature would definitely benefit the UK model, and hopefully other countries, and I'd be interested to know what the general thoughts are on this.

TODO

@sandcha sandcha self-assigned this Feb 24, 2021
@sandcha
Copy link
Collaborator

sandcha commented Feb 24, 2021

Thank you @nikhilwoodruff for this description!
I'm wondering if we couldn't use the week number in the year (from week n°1 to week n°52) to switch between periods and manage offsets. 🤔
Do you have an example in the UK model where you need to switch from a period to another? We could use it as real situation to test different syntax options.

@nikhilwoodruff
Copy link
Contributor Author

Thanks @sandcha - here's an example of a weekly-defined variable we have in the UK model, for Child Benefit. I think that'd be good, though it probably does keep the problem of weeks being truncated by the start and end days of each year?

@bonjourmauko
Copy link
Member

I was taking a look at this, which seems interesting for fiscal scenarios https://en.wikipedia.org/wiki/ISO_week_date

@bonjourmauko bonjourmauko self-assigned this Apr 10, 2021
@bonjourmauko bonjourmauko added kind:feat A feature request, a feature deprecation kind:theme A group of issues, directly tied to an OKR kind:roadmap A group of issues, constituting a delivery roadmap labels Sep 25, 2024
@bonjourmauko bonjourmauko added this to the Add support for weeks milestone Sep 25, 2024
This was referenced Sep 25, 2024
@bonjourmauko bonjourmauko removed the kind:theme A group of issues, directly tied to an OKR label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feat A feature request, a feature deprecation kind:roadmap A group of issues, constituting a delivery roadmap
Projects
Status: Roadmaps/Themes
Development

Successfully merging a pull request may close this issue.

3 participants