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 New Zealand Subdivision Aliases (EN, MI, HASC) #1952

Merged
merged 5 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ All other default values are highlighted with bold:
- OPTIONAL
* - New Zealand
- NZ
- Regions: AUK, BOP, CAN, CIT, GIS, HKB, MBH, MWT, NSN, NTL, OTA, STL, TAS, TKI, WGN, WKO, WTC
- Regions and Special Island Authorities: AUK (Auckland, Tāmaki-Makaurau, AU), BOP (Bay of Plenty, Toi Moana, BP), CAN (Canterbury, Waitaha, CA), CIT (Chatham Islands Territory, Chatham Islands, Wharekauri, CI), GIS (Gisborne, Te Tairāwhiti, GI), HKB (Hawke's Bay, Te Matau-a-Māui, HB), MBH (Marlborough, MA), MWT (Manawatū Whanganui, Manawatū-Whanganui, MW), NSN (Nelson, Whakatū, NE), NTL (Northland, Te Taitokerau, NO), OTA (Otago, Ō Tākou, OT), STL (Southland, Te Taiao Tonga, SO), TAS (Tasman, Te tai o Aorere, TS), TKI (Taranaki, TK), WGN (Greater Wellington, Te Pane Matua Taiao, Wellington, Te Whanganui-a-Tara, WG), WKO (Waikato, WK), WTC (West Coast, Te Tai o Poutini, WC). Subregions: South Canterbury
-
-
* - Nicaragua
Expand Down
109 changes: 67 additions & 42 deletions holidays/countries/new_zealand.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class NewZealand(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
country = "NZ"
observed_label = "%s (observed)"
subdivisions = (
# ISO 3166-2: Regions and Special Island Authorities.
# https://en.wikipedia.org/wiki/ISO_3166-2:NZ
"AUK", # Auckland / Tāmaki-makaurau
"BOP", # Bay of Plenty / Toi Moana
Expand All @@ -35,7 +36,7 @@ class NewZealand(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
"GIS", # Gisborne / Te Tairāwhiti
"HKB", # Hawke's Bay / Te Matau a Māui
"MBH", # Marlborough
"MWT", # Manawatū Whanganui
"MWT", # Manawatū-Whanganui / Manawatū Whanganui
"NSN", # Nelson / Whakatū
"NTL", # Northland / Te Tai tokerau
"OTA", # Otago / Ō Tākou
Expand All @@ -45,27 +46,71 @@ class NewZealand(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
"WGN", # Greater Wellington / Te Pane Matua Taiao
"WKO", # Waikato
"WTC", # West Coast / Te Tai o Poutini
# Subregions:
# https://www.govt.nz/browse/work/public-holidays-and-work/public-holidays-and-anniversary-dates/
"South Canterbury",
arkid15r marked this conversation as resolved.
Show resolved Hide resolved
)

subdivisions_aliases = {
# Fullnames in English and Maori, as well as HASC.
"Auckland": "AUK",
"Tāmaki-Makaurau": "AUK",
"AU": "AUK",
"Bay of Plenty": "BOP",
"Toi Moana": "BOP",
"BP": "BOP",
"Canterbury": "CAN",
"Waitaha": "CAN",
"CA": "CAN",
"Chatham Islands Territory": "CIT",
"Chatham Islands": "CIT", # 1901-1994, as County
"Wharekauri": "CIT",
"CI": "CIT",
"Gisborne": "GIS",
"Te Tairāwhiti": "GIS",
"GI": "GIS",
"Hawke's Bay": "HKB",
"Te Matau-a-Māui": "HKB",
"HB": "HKB",
"Marlborough": "MBH",
"MA": "MBH",
"Manawatū Whanganui": "MWT",
"Manawatū-Whanganui": "MWT",
"MW": "MWT",
"Nelson": "NSN",
"Whakatū": "NSN",
"NE": "NSN",
"Northland": "NTL",
"Te Taitokerau": "NTL",
"NO": "NTL",
"Otago": "OTA",
"Ō Tākou": "OTA",
"OT": "OTA",
"Southland": "STL",
"Te Taiao Tonga": "STL",
"SO": "STL",
"Tasman": "TAS",
"Te tai o Aorere": "TAS",
"TS": "TAS",
"Taranaki": "TKI",
"TK": "TKI",
"Greater Wellington": "WGN",
"Te Pane Matua Taiao": "WGN",
"Wellington": "WGN", # Prev. ISO code from 2010-2015.
"Te Whanganui-a-Tara": "WGN", # Prev. ISO code from 2010-2015.
"WG": "WGN",
"Waikato": "WKO",
"WK": "WKO",
"West Coast": "WTC",
"Te Tai o Poutini": "WTC",
"WC": "WTC",
}
_deprecated_subdivisions = (
"Auckland",
"Canterbury",
"Chatham Islands",
"Hawke's Bay",
"Marlborough",
"Nelson",
"New Plymouth",
"Northland",
"Otago",
"South Canterbury",
"STC",
"Southland",
"Taranaki",
"Waitangi",
"Wellington",
"West Coast",
"Westland", # Correct name is West Coast
"WTL", # Correct code is WTC
# Pre-1893 Naming in Previous Implementations.
"New Plymouth", # 1853-1859, Now Taranaki.
"Westland", # 1873-1876, Now West Coast.
# Unofficial Code.
"STC", # For 'South Canterbury' Subregional Holidays.
"WTL", # Westland, Correct code is WTC (for West Coast).
)

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -186,31 +231,11 @@ def _populate_public_holidays(self):
# Boxing Day
self._add_observed(self._add_christmas_day_two("Boxing Day"), rule=SAT_SUN_TO_NEXT_MON_TUE)

if self.subdiv == "Auckland":
self._populate_subdiv_auk_public_holidays()
elif self.subdiv == "Canterbury":
self._populate_subdiv_can_public_holidays()
elif self.subdiv == "Chatham Islands":
self._populate_subdiv_cit_public_holidays()
elif self.subdiv == "Hawke's Bay":
self._populate_subdiv_hkb_public_holidays()
elif self.subdiv == "Marlborough":
self._populate_subdiv_mbh_public_holidays()
elif self.subdiv == "Nelson":
self._populate_subdiv_nsn_public_holidays()
elif self.subdiv == "Northland":
self._populate_subdiv_ntl_public_holidays()
elif self.subdiv == "Otago":
self._populate_subdiv_ota_public_holidays()
elif self.subdiv in {"New Plymouth", "Taranaki"}:
if self.subdiv == "New Plymouth":
self._populate_subdiv_tki_public_holidays()
elif self.subdiv == "South Canterbury":
self._populate_subdiv_stc_public_holidays()
elif self.subdiv == "Southland":
self._populate_subdiv_stl_public_holidays()
elif self.subdiv == "Wellington":
self._populate_subdiv_wgn_public_holidays()
elif self.subdiv in {"West Coast", "WTL", "Westland"}:
elif self.subdiv in {"WTL", "Westland"}:
self._populate_subdiv_wtc_public_holidays()

def _populate_subdiv_auk_public_holidays(self):
Expand Down
Loading
Loading