Skip to content

WLG holidays fix #1102

@conighion

Description

@conighion

Added two holidays

Wellington Anniversary Day - Nearest Monday to Jan 22
Auckland Anniversary Day - Nearest Monday to Jan 29

Holiday("Wellington Anniversary Day", month=1, day=22, observance=monday_nearest),
Holiday("Auckland Anniversary Day", month=1, day=29, observance=monday_nearest),

where

def monday_nearest(dt: datetime) -> datetime:
"""
Return the Monday nearest to the given date (dt); Used for Wellington and Auckland anniversaries.
"""
# If already Monday
if dt.weekday() == 0:
return dt

# Previous Monday
prev_mon = dt - timedelta(days=dt.weekday())
# Next Monday
next_mon = prev_mon + timedelta(days=7)

# Pick whichever Monday is closer
if (dt - prev_mon) <= (next_mon - dt):
    return prev_mon
else:
    return next_mon

Fix for King's Birthday (first monday of June not second):
Holiday("King's Birthday", month=6, day=1, offset=DateOffset(weekday=MO(1))),

Also need to change for the first two day of the year as in:
Holiday("New Year's Day", month=1, day=1, observance=next_monday),
Holiday("Day After New Year's Day", month=1, day=2, observance=next_monday_or_tuesday),

and also added the observance for the Anzac Day
Holiday("Anzac Day", month=4, day=25, observance=next_monday),

Attaching the file with all the changes

Also Labour Day is the 4th Monday of October not the last.

Holiday("Labour Day", month=10, day=1, offset=DateOffset(weekday=MO(4))),

I checked with refinitiv and the dates are matching for 2020 to 2025.

Finally an ad hoc holiday for

Holiday("Queen Elizabeth II Memorial Day", year=2022, month=9, day=26),

wlg_script.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions