8000 Add Anguilla holidays · Issue #2410 · vacanza/holidays · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Add Anguilla holidays #2410

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

Closed
arkid15r opened this issue Apr 3, 2025 · 6 comments · Fixed by #2615
Closed

Add Anguilla holidays #2410

arkid15r opened this issue Apr 3, 2025 · 6 comments · Fixed by #2615
Assignees

Comments

@Prateekshit73
Copy link
Collaborator
Prateekshit73 commented Jun 2, 2025

@KJhellico
Copy link
Collaborator

1-3 (in fact, it is one address, in terms of citation) - source for 2011-2022 dates, looks very good
4 (Public Holidays Act) - it's only one page, but full Act also doesn't contain holidays list
5 (Public Holidays Regulations) - is also incomplete, but there is 7 :)
6 - good
7 - very good

Also official sources: 2021, 2023, 2025.

@Prateekshit73
Copy link
Collaborator

Is this a good way to implement?

    # Anguilla Day is on May 30th
    anguilla_day = self._add_holiday_may_30(tr("Anguilla Day"))
    
    # Whit Monday is already defined
    whit_monday = self._add_whit_monday(tr("Whit Monday"))
    
    # If Anguilla Day (May 30th) coincides with Whit Monday, move Anguilla Day to May 31st
    if self._is_same_day(anguilla_day, whit_monday):
        anguilla_day = self._add_holiday_may_31(tr("Anguilla Day"))
    
    # If Anguilla Day falls on a Saturday or Sunday, move to the next Monday
    # If that Monday is Whit Monday, move Anguilla Day to the following Tuesday
    if self._is_weekend(anguilla_day):
        next_monday = self._add_observed(anguilla_day, rule=SAT_SUN_TO_NEXT_MON)
        if self._is_same_day(next_monday, whit_monday):
            anguilla_day = self._add_observed(next_monday, rule=TO_NEXT_TUE)
        else:
            anguilla_day = next_monday

Reference : REVISED REGULATIONS OF ANGUILLA

@KJhellico
Copy link
Collaborator

Discussing code chunks in issue comments is a bit strange, but...

if self._is_same_day(anguilla_day, whit_monday):

What is self._is_same_day? The smell of AI in this code, I sense. 😉

anguilla_day = self._add_holiday_may_30(tr("Anguilla Day"))

After that, holiday already exists, and if it coincides with Whit Monday, it must be moved using _move_holiday, but this method will move all holidays on the specified date. So you need to check before adding.

@Prateekshit73
Copy link
Collaborator

What is self._is_same_day? The smell of AI in this code, I sense. 😉

Thank you for pointing that out! I got stuck and sought assistance, but I thought it would be best to first ask here if it’s okay to proceed with that approach. I apologize for using the Issues section for this and will ensure to handle it more appropriately going forward.

@PPsyrius
Copy link
Collaborator
PPsyrius commented Jun 4, 2025

This works for me, but probably could be simplified:

from holidays.calendars.gregorian import MAY, JUN
        # Whit Monday.
        whit_monday = self._add_whit_monday(tr("Whit Monday"))
        
        dt = date(self._year, MAY, 30)
        if whit_monday == dt:
            dt = (MAY, 31)
        elif self._is_saturday(dt):
            dt = (JUN, 2 if whit_monday == date(self._year, JUN, 1) else 1)
        elif self._is_sunday(dt):
            dt = (JUN, 1) if whit_monday == date(self._year, MAY, 31) else (MAY, 31)
        # Anguilla Day.
        anguilla_day = self._add_holiday(tr("Anguilla Day"), dt)

Edit: Version 2

from datetime import date

from holidays.calendars.gregorian import MAY, _timedelta
        # Whit Monday.
        whit_monday = self._add_whit_monday(tr("Whit Monday"))
        
        dt = date(self._year, MAY, 30)
        # Step 1: Move if Weekend.
        if self._is_weekend(dt):
            dt = _timedelta(dt, +2) if self._is_saturday(dt) else _timedelta(dt, +1)
        # Step 2: Move (again) if Whit Monday.
        if whit_monday == dt:
            dt = _timedelta(dt, +1)
        # Anguilla Day.
        anguilla_day = self._add_holiday(tr("Anguilla Day"), dt)

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

Successfully merging a pull request may close this issue.

4 participants
0