0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-10 23:00:09 +08:00
discourse/plugins/discourse-calendar/vendor/holidays/lib/generated_definitions/nz.rb
Gary Pendergast 1983a44812
CHORE: Import holiday definition updates. (#34835)
The Discourse Calendar plugin includes a hard fork of the [holidays
gem](https://github.com/holidays/holidays/).

There have been some updates to the original gem since the fork, this
change pulls in the major updates.

---------

Co-authored-by: Ivan Kuchin <tadump+git@gmail.com>
Co-authored-by: Phil Peble <ppeble@activecampaign.com>
Co-authored-by: Claudio Rodrigo Pereyra Diaz <claudiorodrigo@pereyradiaz.com.ar>
Co-authored-by: Michael Smith <michael.smith076@msd.govt.nz>
Co-authored-by: Lairton Mendes <lairton.mendes@gmail.com>
Co-authored-by: Lars Aurbakken <Lars.Aurbakken@ist.com>
Co-authored-by: i2chris <35810281+i2chris@users.noreply.github.com>
Co-authored-by: Dennis van de Hoef <dennisvdhoef@gmail.com>
2025-09-17 16:07:06 +10:00

105 lines
5.4 KiB
Ruby
Vendored

# encoding: utf-8
module Holidays
# This file is generated by the Ruby Holidays gem.
#
# Definitions loaded: definitions/nz.yaml
#
# All the definitions are available at https://github.com/holidays/holidays
module NZ # :nodoc:
def self.defined_regions
[:nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ne, :nz_ot, :nz_ta, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl]
end
def self.holidays_by_month
{
0 => [{:function => "easter(year)", :function_arguments => [:year], :function_modifier => -2, :name => "Good Friday", :regions => [:nz]},
{:function => "easter(year)", :function_arguments => [:year], :function_modifier => 1, :name => "Easter Monday", :regions => [:nz]},
{:function => "matariki(year)", :function_arguments => [:year], :name => "Matariki", :regions => [:nz]}],
1 => [{:mday => 1, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:nz]},
{:mday => 2, :observed => "to_weekday_if_boxing_weekend(date)", :observed_arguments => [:date], :name => "Day after New Year's Day", :regions => [:nz]},
{:mday => 17, :name => "Southland Anniversary Day", :regions => [:nz_sl]},
{:mday => 22, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Wellington Anniversary Day", :regions => [:nz_we]},
{:mday => 29, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Auckland Anniversary Day", :regions => [:nz_ak]},
{:mday => 29, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Northland Anniversary Day", :regions => [:nz_nl]}],
2 => [{:mday => 1, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Nelson Anniversary Day", :regions => [:nz_ne]},
{:mday => 6, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Waitangi Day", :regions => [:nz]}],
3 => [{:mday => 23, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Otago Anniversary Day", :regions => [:nz_ot]},
{:wday => 1, :week => 2, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Taranaki Anniversary Day", :regions => [:nz_ta]}],
4 => [{:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "ANZAC Day", :regions => [:nz]}],
6 => [{:wday => 1, :week => 1, :year_ranges => { :until => 2022 },:name => "Queen's Birthday", :regions => [:nz]},
{:wday => 1, :week => 1, :year_ranges => { :from => 2023 },:name => "King's Birthday", :regions => [:nz]}],
9 => [{:wday => 1, :week => 4, :name => "Dominion Day", :regions => [:nz_sc]}],
10 => [{:wday => 1, :week => 1, :observed => "previous_friday(date)", :observed_arguments => [:date], :name => "Hawke's bay Anniversary Day", :regions => [:nz_hb]},
{:wday => 1, :week => 4, :name => "Labour Day", :regions => [:nz]},
{:wday => 1, :week => 4, :observed => "next_week(date)", :observed_arguments => [:date], :name => "Marlborough Anniversary Day", :regions => [:nz_mb]}],
11 => [{:wday => 5, :week => 2, :name => "Canterbury Anniversary Day", :regions => [:nz_ca]},
{:mday => 30, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Chatham Island Anniversary Day", :regions => [:nz_ch]}],
12 => [{:mday => 1, :observed => "closest_monday(date)", :observed_arguments => [:date], :name => "Westland Anniversary Day", :regions => [:nz_wl]},
{:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:nz]},
{:mday => 26, :observed => "to_weekday_if_boxing_weekend(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:nz]}]
}
end
def self.custom_methods
{
"closest_monday(date)" => Proc.new { |date|
if [1, 2, 3, 4].include?(date.wday)
date -= (date.wday - 1)
elsif 0 == date.wday
date += 1
else
date += 8 - date.wday
end
date
},
"previous_friday(date)" => Proc.new { |date|
date - 3
},
"next_week(date)" => Proc.new { |date|
date + 7
},
"matariki(year)" => Proc.new { |year|
@matariki_dates ||= {
2022 => Date.civil(2022, 6, 24),
2023 => Date.civil(2023, 7, 14),
2024 => Date.civil(2024, 6, 28),
2025 => Date.civil(2025, 6, 20),
2026 => Date.civil(2026, 7, 10),
2027 => Date.civil(2027, 6, 25),
2028 => Date.civil(2028, 7, 14),
2029 => Date.civil(2029, 7, 6),
2030 => Date.civil(2030, 6, 21),
2031 => Date.civil(2031, 7, 11),
2032 => Date.civil(2032, 7, 2),
2033 => Date.civil(2033, 6, 24),
2034 => Date.civil(2034, 7, 7),
2035 => Date.civil(2035, 6, 29),
2036 => Date.civil(2036, 7, 18),
2037 => Date.civil(2037, 7, 10),
2038 => Date.civil(2038, 6, 25),
2039 => Date.civil(2039, 7, 15),
2040 => Date.civil(2040, 7, 6),
2041 => Date.civil(2041, 7, 19),
2042 => Date.civil(2042, 7, 11),
2043 => Date.civil(2043, 7, 3),
2044 => Date.civil(2044, 6, 24),
2045 => Date.civil(2045, 7, 7),
2046 => Date.civil(2046, 6, 29),
2047 => Date.civil(2047, 7, 19),
2048 => Date.civil(2048, 7, 3),
2049 => Date.civil(2049, 6, 25),
2050 => Date.civil(2050, 7, 15),
2051 => Date.civil(2051, 6, 30),
2052 => Date.civil(2052, 6, 21),
}
@matariki_dates[year]
},
}
end
end
end