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

BUG: duplicate shifted holiday in California #528

Closed
joooeey opened this issue Jul 15, 2020 · 6 comments · Fixed by #539
Closed

BUG: duplicate shifted holiday in California #528

joooeey opened this issue Jul 15, 2020 · 6 comments · Fixed by #539
Labels
Projects

Comments

@joooeey
Copy link

joooeey commented Jul 15, 2020

from workalendar.usa import California

cal = California()

cal.holidays(2019)
Out[13]: 
[(datetime.date(2019, 1, 1), 'New year'),
 (datetime.date(2019, 1, 21), 'Birthday of Martin Luther King, Jr.'),
 (datetime.date(2019, 2, 18), "Washington's Birthday"),
 (datetime.date(2019, 3, 31), 'Cesar Chavez Day'),
 (datetime.date(2019, 4, 1), 'Cesar Chavez Day (Observed)'),  # <===============
 (datetime.date(2019, 4, 1), 'Cesar Chavez Day (Observed)'),  # <===============
 (datetime.date(2019, 5, 27), 'Memorial Day'),
 (datetime.date(2019, 7, 4), 'Independence Day'),
 (datetime.date(2019, 9, 2), 'Labor Day'),
 (datetime.date(2019, 11, 11), 'Veterans Day'),
 (datetime.date(2019, 11, 28), 'Thanksgiving Day'),
 (datetime.date(2019, 11, 29), 'Thanksgiving Friday'),
 (datetime.date(2019, 12, 25), 'Christmas Day')]

Note that Cesar Chavez Day (Observed) is duplicated.

This does not occur for 2017, 2018, 2020, and 2021. I've just tested those five years. The same issue occurs with 2019 in the CaliforniaEducation calendar.

I noticed this issue because it breaks a version of my test for PR #527.

@brunobord
Copy link
Member

thank you for the bug report, very "interesting" bug. I'll get into it as soon as I can.

@brunobord brunobord added the bug label Jul 16, 2020
@brunobord brunobord added this to Warming up in Workalendar via automation Jul 16, 2020
@brunobord brunobord moved this from Warming up to To Do in Workalendar Jul 16, 2020
@joooeey
Copy link
Author

joooeey commented Jul 16, 2020

I just looked into this. The shift day is computed twice (and differently) in workalendar/usa/core.py. Saturday is shifted to Friday and Sunday to Monday in def shift and if the holiday falls on a Sunday it is shifted to Monday in def get_cesar_chavez_days.

Here's some info on how state holidays in California work. It says about the shift holidays:

*When a holiday falls on a Saturday, employees shall receive holiday credit.
**When a holiday falls on a Sunday, the holiday is observed on the following Monday

I could not find any source stating that Cesar Chavez Day is shifted any differently than other holidays.

Hence, I think this bug should be solved by not doing any special shifting for Cesar Chavez Day, i.e. have a def get_cesar_chavez_day function just like all the other holiday functions that returns a holiday on March 31 and no extra shift day.

However I noticed two other, separate issues:

  • As per the link above, California state holidays falling on a Saturday are not actually shifted to Friday but result in holiday credit instead. In usa/core.py we shift them to Friday.
  • Per Wikipedia Cesar Chavez Day is a state holiday in a few states, in workalendar we only have it in California. So we're inconsistent. Also, it doesn't seem to be a holiday for most workers in California.

I'm not gonna touch these two bullet points as this looks like a job for an American.

@brunobord brunobord moved this from To Do to Working in Workalendar Jul 17, 2020
@brunobord
Copy link
Member

Seems like Cesar Chavez day is an optional holiday in Colorado. That might be the reason why, at the time, I introduced it as a "core" holiday, with an "include_" flag to allow integrators to activate it or not depending on their context.

I need to dig a bit further on the duplicates you've found, though.

@brunobord
Copy link
Member

ok, I think I have a lead, here.

Effectively, Chavez Day seems to be an exception when it comes to weekend-shifting.
But if your calendar includes the Cesar Chavez Day and if you're not in California, it may follow the same pattern as other holidays in other states (Shift to FRI if it happens on SAT, and shift to MON if it happens on SUN).

I think it's possible to have a satisfying procedure that would keep the usual behaviour and take the Californian exception the way it should be.

brunobord added a commit that referenced this issue Aug 21, 2020
brunobord added a commit that referenced this issue Aug 21, 2020
brunobord added a commit that referenced this issue Aug 24, 2020
Workalendar automation moved this from Working to Done Aug 28, 2020
@brunobord
Copy link
Member

Bug fixed, you can use the latest (10.4.0) release:

I'm still working my way on the iCal export feature, soon to be ready.

@joooeey
Copy link
Author

joooeey commented Sep 22, 2020

Effectively, Chavez Day seems to be an exception when it comes to weekend-shifting.

It would be sweet to document the source for this statement. To me it looked like this was an implementation mistake. I couldn't find any official info that shifting works differently for Cesar Chavez Day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Workalendar
  
Done/Closed/Published
Development

Successfully merging a pull request may close this issue.

2 participants