-
Notifications
You must be signed in to change notification settings - Fork 14
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 FiscalWeek and fiscal_week attribute to FiscalDate and FiscalDateTime #17
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # fiscalyear.py
"""returns: The fiscal week | ||
:rtype: int | ||
""" | ||
return -(-self.fiscal_day // 7) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamjstewart Let me know if you'd rather I just imported and used math.ceil
Can you add a |
I built and pushed a quick FiscalWeek implementation based off of FiscalDay, but then realized maybe this isn't the correct spec. This implementation calculates the week based on the number of 7-day periods from the start of the year. I think the more typical way fiscal weeks are counted is based on a user-overridable "start of week" (e.g. Sunday or Monday), which means the first and last weeks of the year are weird lengths and there's a bonus 53rd week every handful of years. Or, put another way, the first week starts on whatever calendar day is defined as the first day of the year. The first week is from that day until the day before the "start of the week," and then the weeks are counted normally until the last week which runs until the day before the new calendar year starts. I pushed up what I have so far (it's 99% copy and pasted from FiscalDay with minor tweaks). I'm happy to document it as-written or I can find some time to look at it with the alternative spec described above. Let me know what you want to do. Edit: Actually, and without thinking too hard about it, that might be a relatively straightforward extension of what I just built. |
Hmm, I see what you mean. This is getting pretty complicated. Let's go back to the original issue and try to decide on a single robust definition of what a "week" is and what the API should return. |
I had some time so I thought I'd take a whack at this. No urgency at all on my end on as far as release, I just thought it'd be nice to close out #10.
This PR depends on the fix from #16. Otherwise it's a tiny PR. Implementation is terse, but maybe a bit opaque, so let me know what you think.