holidays 11.0.0 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a50db0819861773f47fbb4a0d9a4ae915252de055df2469ce1c0bde7d37a841
4
- data.tar.gz: 7ab200f4615da49c92460f1bc7f6ccda43e4d955fac918425b1d9e78199592e1
3
+ metadata.gz: 4bb2781ba121d283464899429145c411a25aaa5ff4a6a0ff5811424a56632655
4
+ data.tar.gz: 3c85c4273f1d23a9e62dbc570786bac1e7f9141557fe319b941f89b3644d096a
5
5
  SHA512:
6
- metadata.gz: b769b76632a24b952c132ccaee4e76dfb7b6f03c84004b19cd4243e6c2fc79c1756d131e6e7d275c36f62943f79a19833cc44e7051b02de3c184312823236cd7
7
- data.tar.gz: b374d432b537393e8afbe38dfc3fee5c20f70aa35e32c4c46bb2b8b13f9f5c4422662f3d083cf0f2e6a5db6cd457e2d941898a9596387203e6f4eb88a8765cb8
6
+ metadata.gz: 4bbbdbf548d4dfaad1806ad22a1fbd75036148f5d822dc9623fe469c60464580615e357e1761bec427974a03c33403487478167d22a62dc91f2dffd83495eeb2
7
+ data.tar.gz: 92defd8e455e8f29075fe75354cf5348efa6d4c8d2df7ecd1c42aa2015adf8b58858284dfc4797616e2970fa862b8747e03cf33f4442d5b6f82eddf7ab5c3efe
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Ruby Holidays Gem CHANGELOG
2
2
 
3
+ ## 11.1.0
4
+
5
+ * Add `Holidays.region_names` and `Holidays.region_name(region)` to expose the English name of each region ([#160](https://github.com/holidays/holidays/issues/160)). Names are the ISO 3166 English short names added in [definitions #325](https://github.com/holidays/definitions/pull/325). `region_name` returns `nil` for an unknown region. `available_regions` is unchanged.
6
+ * Update to [v8.0.1 definitions](https://github.com/holidays/definitions/releases/tag/v8.0.1). Please see the changelog for the definition details.
7
+ * Fix `gb` Christmas and Boxing Day observed dates when Christmas falls on a Sunday ([#396](https://github.com/holidays/holidays/issues/396)). Boxing Day is now observed on Monday the 26th and Christmas Day is substituted to Tuesday the 27th. Callers matching on holiday name will see these two names swap for the affected dates.
8
+ * Fix `ph` National Heroes Day when August 31st falls on a Sunday ([definitions issue-345](https://github.com/holidays/definitions/issues/345))
9
+
3
10
  ## 11.0.0
4
11
 
5
12
  * Update to [v8.0.0 definitions](https://github.com/holidays/definitions/releases/tag/v8.0.0). Please see the changelog for the definition details.
data/README.md CHANGED
@@ -243,6 +243,31 @@ Holidays.available_regions
243
243
  => [:ar, :at, ..., :sg] # this will be a big array
244
244
  ```
245
245
 
246
+ #### Return region names
247
+
248
+ Return the English name of every region:
249
+
250
+ ```ruby
251
+ Holidays.region_names
252
+ => {:ar=>"Argentina", :at=>"Austria", ..., :sg=>"Singapore"} # this will be a big hash
253
+ ```
254
+
255
+ Return the English name of a single region:
256
+
257
+ ```ruby
258
+ Holidays.region_name(:gb_eng)
259
+ => "England"
260
+ ```
261
+
262
+ Unknown regions return `nil`:
263
+
264
+ ```ruby
265
+ Holidays.region_name(:not_a_region)
266
+ => nil
267
+ ```
268
+
269
+ Names are the [ISO 3166](https://www.iso.org/iso-3166-country-codes.html) English short names where one exists. Subregions and non-country regions (stock exchanges, central banks, shipping carriers) use their common English name.
270
+
246
271
  ## Loading Custom Definitions on the fly
247
272
 
248
273
  In addition to the [provided definitions](https://github.com/holidays/definitions) you can load custom definitions file on the fly and use them immediately.
@@ -3,4 +3,6 @@ module Holidays
3
3
  REGIONS = [:ar, :at, :au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_wa, :au_tas, :au_tas_south, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne, :be_fr, :be_nl, :br, :bg_en, :bg_bg, :ca, :ca_qc, :ca_ab, :ca_sk, :ca_on, :ca_bc, :ca_nb, :ca_mb, :ca_ns, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_yt, :us, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cl, :co, :cr, :cy, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_sorbian, :de_th_cath, :de_sn, :de_st, :de_be, :de_mv, :de_by_cath, :de_by_augsburg, :de_th, :de_bb, :de_hb, :de_hh, :de_ni, :de_sh, :ecbtarget, :ee, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :federalreserve, :federalreservebanks, :fedex, :fi, :fr_a, :fr_m, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :gb_sct, :im, :gb_iom, :ge, :gr, :hr, :hk, :hu, :ie, :il, :in, :in_wb, :in_od, :in_tr, :in_mh, :in_ar, :in_mz, :in_br, :in_hp, :in_gj, :in_sk, :in_ts, :in_jh, :in_py, :in_kl, :in_ka, :in_jk, :in_ap, :in_cg, :in_hr, :in_mp, :in_pb, :in_nl, :in_as, :in_ga, :is, :it, :it_ve, :it_tv, :it_vr, :it_pd, :it_fi, :it_ge, :it_to, :it_rm, :it_vi, :it_bl, :it_ro, :ke, :kr, :kz, :li, :lt, :lv, :ma, :mc, :mt_mt, :mt_en, :mx, :mx_pue, :nerc, :nl, :lu, :no, :nyse, :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, :pe, :ph, :pl, :pt, :pt_li, :pt_po, :ro, :rs_cyrl, :rs_la, :ru, :se, :tn, :tr, :tsx, :ua, :us_fl, :us_al, :us_la, :us_ct, :us_de, :us_gu, :us_hi, :us_in, :us_ky, :us_nj, :us_nc, :us_nd, :us_pa, :us_pr, :us_tn, :us_ga, :us_ms, :us_id, :us_ar, :us_tx, :us_dc, :us_md, :us_va, :us_vt, :us_ak, :us_ca, :us_me, :us_ma, :us_ne, :us_mo, :us_sc, :us_wv, :us_vi, :us_ut, :us_ri, :us_az, :us_co, :us_il, :us_mt, :us_nm, :us_ny, :us_oh, :us_mi, :us_mn, :us_nv, :us_or, :us_sd, :us_wa, :us_wi, :us_wy, :us_ia, :us_ks, :us_nh, :us_ok, :unitednations, :ups, :za, :ve, :sk, :si, :jp, :vn, :sg, :my, :th, :ng]
4
4
 
5
5
  PARENT_REGION_LOOKUP = {ar: :ar, at: :at, au: :au, au_nsw: :au, au_vic: :au, au_qld: :au, au_nt: :au, au_act: :au, au_sa: :au, au_wa: :au, au_tas: :au, au_tas_south: :au, au_qld_cairns: :au, au_qld_brisbane: :au, au_tas_north: :au, au_vic_melbourne: :au, be_fr: :be_fr, be_nl: :be_nl, br: :br, bg_en: :bg, bg_bg: :bg, ca: :ca, ca_qc: :ca, ca_ab: :ca, ca_sk: :ca, ca_on: :ca, ca_bc: :ca, ca_nb: :ca, ca_mb: :ca, ca_ns: :ca, ca_pe: :ca, ca_nl: :ca, ca_nt: :ca, ca_nu: :ca, ca_yt: :ca, us: :us, ch_zh: :ch, ch_be: :ch, ch_lu: :ch, ch_ur: :ch, ch_sz: :ch, ch_ow: :ch, ch_nw: :ch, ch_gl: :ch, ch_zg: :ch, ch_fr: :ch, ch_so: :ch, ch_bs: :ch, ch_bl: :ch, ch_sh: :ch, ch_ar: :ch, ch_ai: :ch, ch_sg: :ch, ch_gr: :ch, ch_ag: :ch, ch_tg: :ch, ch_ti: :ch, ch_vd: :ch, ch_ne: :ch, ch_ge: :ch, ch_ju: :ch, ch_vs: :ch, ch: :ch, cl: :cl, co: :co, cr: :cr, cy: :cy, cz: :cz, dk: :dk, de: :de, de_bw: :de, de_by: :de, de_he: :de, de_nw: :de, de_rp: :de, de_sl: :de, de_sn_sorbian: :de, de_th_cath: :de, de_sn: :de, de_st: :de, de_be: :de, de_mv: :de, de_by_cath: :de, de_by_augsburg: :de, de_th: :de, de_bb: :de, de_hb: :de, de_hh: :de, de_ni: :de, de_sh: :de, ecbtarget: :ecbtarget, ee: :ee, es_pv: :es, es_na: :es, es_an: :es, es_ib: :es, es_cm: :es, es_mu: :es, es_m: :es, es_ar: :es, es_cl: :es, es_cn: :es, es_lo: :es, es_ga: :es, es_ce: :es, es_o: :es, es_ex: :es, es: :es, es_ct: :es, es_v: :es, es_vc: :es, federalreserve: :federalreserve, federalreservebanks: :federalreservebanks, fedex: :fedex, fi: :fi, fr_a: :fr, fr_m: :fr, fr: :fr, gb: :gb, gb_eng: :gb, gb_wls: :gb, gb_eaw: :gb, gb_nir: :gb, gb_con: :gb, je: :gb, gb_jsy: :gb, gg: :gb, gb_gsy: :gb, gb_sct: :gb, im: :gb, gb_iom: :gb, ge: :ge, gr: :gr, hr: :hr, hk: :hk, hu: :hu, ie: :ie, il: :il, in: :in, in_wb: :in, in_od: :in, in_tr: :in, in_mh: :in, in_ar: :in, in_mz: :in, in_br: :in, in_hp: :in, in_gj: :in, in_sk: :in, in_ts: :in, in_jh: :in, in_py: :in, in_kl: :in, in_ka: :in, in_jk: :in, in_ap: :in, in_cg: :in, in_hr: :in, in_mp: :in, in_pb: :in, in_nl: :in, in_as: :in, in_ga: :in, is: :is, it: :it, it_ve: :it, it_tv: :it, it_vr: :it, it_pd: :it, it_fi: :it, it_ge: :it, it_to: :it, it_rm: :it, it_vi: :it, it_bl: :it, it_ro: :it, ke: :ke, kr: :kr, kz: :kz, li: :li, lt: :lt, lv: :lv, ma: :ma, mc: :mc, mt_mt: :mt_mt, mt_en: :mt_en, mx: :mx, mx_pue: :mx, nerc: :nerc, nl: :nl, lu: :lu, no: :no, nyse: :nyse, nz: :nz, nz_sl: :nz, nz_we: :nz, nz_ak: :nz, nz_nl: :nz, nz_ne: :nz, nz_ot: :nz, nz_ta: :nz, nz_sc: :nz, nz_hb: :nz, nz_mb: :nz, nz_ca: :nz, nz_ch: :nz, nz_wl: :nz, pe: :pe, ph: :ph, pl: :pl, pt: :pt, pt_li: :pt, pt_po: :pt, ro: :ro, rs_cyrl: :rs_cyrl, rs_la: :rs_la, ru: :ru, se: :se, tn: :tn, tr: :tr, tsx: :tsx, ua: :ua, us_fl: :us, us_al: :us, us_la: :us, us_ct: :us, us_de: :us, us_gu: :us, us_hi: :us, us_in: :us, us_ky: :us, us_nj: :us, us_nc: :us, us_nd: :us, us_pa: :us, us_pr: :us, us_tn: :us, us_ga: :us, us_ms: :us, us_id: :us, us_ar: :us, us_tx: :us, us_dc: :us, us_md: :us, us_va: :us, us_vt: :us, us_ak: :us, us_ca: :us, us_me: :us, us_ma: :us, us_ne: :us, us_mo: :us, us_sc: :us, us_wv: :us, us_vi: :us, us_ut: :us, us_ri: :us, us_az: :us, us_co: :us, us_il: :us, us_mt: :us, us_nm: :us, us_ny: :us, us_oh: :us, us_mi: :us, us_mn: :us, us_nv: :us, us_or: :us, us_sd: :us, us_wa: :us, us_wi: :us, us_wy: :us, us_ia: :us, us_ks: :us, us_nh: :us, us_ok: :us, unitednations: :unitednations, ups: :ups, za: :za, ve: :southamerica, sk: :europe, si: :europe, jp: :jp, vn: :vn, sg: :sg, my: :my, th: :th, ng: :ng}
6
+
7
+ REGION_NAMES = {:ar => "Argentina", :at => "Austria", :au => "Australia", :au_act => "Australian Capital Territory", :au_nsw => "New South Wales", :au_nt => "Northern Territory", :au_qld => "Queensland", :au_qld_brisbane => "Brisbane", :au_qld_cairns => "Cairns", :au_sa => "South Australia", :au_tas => "Tasmania", :au_tas_north => "Northern Tasmania", :au_tas_south => "Southern Tasmania", :au_vic => "Victoria", :au_vic_melbourne => "Melbourne", :au_wa => "Western Australia", :be_fr => "Belgium (French)", :be_nl => "Belgium (Dutch)", :br => "Brazil", :bg_bg => "Bulgaria", :bg_en => "Bulgaria", :ca => "Canada", :ca_ab => "Alberta", :ca_bc => "British Columbia", :ca_mb => "Manitoba", :ca_nb => "New Brunswick", :ca_nl => "Newfoundland and Labrador", :ca_ns => "Nova Scotia", :ca_nt => "Northwest Territories", :ca_nu => "Nunavut", :ca_on => "Ontario", :ca_pe => "Prince Edward Island", :ca_qc => "Quebec", :ca_sk => "Saskatchewan", :ca_yt => "Yukon", :us => "United States", :ch => "Switzerland", :ch_ag => "Aargau", :ch_ai => "Appenzell Innerrhoden", :ch_ar => "Appenzell Ausserrhoden", :ch_be => "Bern", :ch_bl => "Basel-Landschaft", :ch_bs => "Basel-Stadt", :ch_fr => "Fribourg", :ch_ge => "Genève", :ch_gl => "Glarus", :ch_gr => "Graubünden", :ch_ju => "Jura", :ch_lu => "Luzern", :ch_ne => "Neuchâtel", :ch_nw => "Nidwalden", :ch_ow => "Obwalden", :ch_sg => "Sankt Gallen", :ch_sh => "Schaffhausen", :ch_so => "Solothurn", :ch_sz => "Schwyz", :ch_tg => "Thurgau", :ch_ti => "Ticino", :ch_ur => "Uri", :ch_vd => "Vaud", :ch_vs => "Valais", :ch_zg => "Zug", :ch_zh => "Zürich", :cl => "Chile", :co => "Colombia", :cr => "Costa Rica", :cy => "Cyprus", :cz => "Czechia", :dk => "Denmark", :de => "Germany", :de_bb => "Brandenburg", :de_be => "Berlin", :de_bw => "Baden-Württemberg", :de_by => "Bayern", :de_by_augsburg => "Augsburg (Bayern)", :de_by_cath => "Bayern (Catholic regions)", :de_hb => "Bremen", :de_he => "Hessen", :de_hh => "Hamburg", :de_mv => "Mecklenburg-Vorpommern", :de_ni => "Niedersachsen", :de_nw => "Nordrhein-Westfalen", :de_rp => "Rheinland-Pfalz", :de_sh => "Schleswig-Holstein", :de_sl => "Saarland", :de_sn => "Sachsen", :de_sn_sorbian => "Sachsen (Sorbian regions)", :de_st => "Sachsen-Anhalt", :de_th => "Thüringen", :de_th_cath => "Thüringen (Catholic regions)", :ecbtarget => "ECB TARGET (European Central Bank)", :ee => "Estonia", :es => "Spain", :es_an => "Andalucía", :es_ar => "Aragón", :es_ce => "Ceuta", :es_cl => "Castilla y León", :es_cm => "Castilla-La Mancha", :es_cn => "Canary Islands", :es_ct => "Cataluña", :es_ex => "Extremadura", :es_ga => "Galicia", :es_ib => "Islas Baleares", :es_lo => "Rioja, La", :es_m => "Madrid", :es_mu => "Murcia", :es_na => "Navarra", :es_o => "Asturias", :es_pv => "País Vasco", :es_v => "Valencia/València", :es_vc => "Comunidad Valenciana", :federalreserve => "Federal Reserve", :federalreservebanks => "Federal Reserve Banks", :fedex => "FedEx", :fi => "Finland", :fr => "France", :fr_a => "Alsace", :fr_m => "Moselle", :gb => "United Kingdom", :gb_con => "Cornwall", :gb_eaw => "England and Wales", :gb_eng => "England", :gb_gsy => "Guernsey", :gb_iom => "Isle of Man", :gb_jsy => "Jersey", :gb_nir => "Northern Ireland", :gb_sct => "Scotland", :gb_wls => "Wales", :gg => "Guernsey", :im => "Isle of Man", :je => "Jersey", :ge => "Georgia", :gr => "Greece", :hr => "Croatia", :hk => "Hong Kong", :hu => "Hungary", :ie => "Ireland", :il => "Israel", :in => "India", :in_ap => "Andhra Pradesh", :in_ar => "Arunachal Pradesh", :in_as => "Assam", :in_br => "Bihar", :in_cg => "Chhattisgarh", :in_ga => "Goa", :in_gj => "Gujarat", :in_hp => "Himachal Pradesh", :in_hr => "Haryana", :in_jh => "Jharkhand", :in_jk => "Jammu and Kashmir", :in_ka => "Karnataka", :in_kl => "Kerala", :in_mh => "Maharashtra", :in_mp => "Madhya Pradesh", :in_mz => "Mizoram", :in_nl => "Nagaland", :in_od => "Odisha", :in_pb => "Punjab", :in_py => "Pondicherry", :in_sk => "Sikkim", :in_tr => "Tripura", :in_ts => "तेलंगाना", :in_wb => "West Bengal", :is => "Iceland", :it => "Italy", :it_bl => "Belluno", :it_fi => "Firenze", :it_ge => "Genova", :it_pd => "Padova", :it_rm => "Roma", :it_ro => "Rovigo", :it_to => "Torino", :it_tv => "Treviso", :it_ve => "Venezia", :it_vi => "Vicenza", :it_vr => "Verona", :ke => "Kenya", :kr => "South Korea", :kz => "Kazakhstan", :li => "Liechtenstein", :lt => "Lithuania", :lv => "Latvia", :ma => "Morocco", :mc => "Monaco", :mt_mt => "Malta", :mt_en => "Malta", :mx => "Mexico", :mx_pue => "Puebla", :nerc => "North American Electric Reliability Corporation", :nl => "Netherlands", :lu => "Luxembourg", :no => "Norway", :nyse => "New York Stock Exchange", :nz => "New Zealand", :nz_ak => "Auckland", :nz_ca => "Canterbury", :nz_ch => "Chatham Islands", :nz_hb => "Hawke's Bay", :nz_mb => "Marlborough", :nz_ne => "Nelson", :nz_nl => "Northland", :nz_ot => "Otago", :nz_sc => "South Canterbury", :nz_sl => "Southland", :nz_ta => "Taranaki", :nz_we => "Wellington", :nz_wl => "Westland", :pe => "Peru", :ph => "Philippines", :pl => "Poland", :pt => "Portugal", :pt_li => "Lisbon", :pt_po => "Porto", :ro => "Romania", :rs_cyrl => "Serbia", :rs_la => "Serbia", :ru => "Russian Federation", :se => "Sweden", :tn => "Tunisia", :tr => "Türkiye", :tsx => "Toronto Stock Exchange", :ua => "Ukraine", :us_ak => "Alaska", :us_al => "Alabama", :us_ar => "Arkansas", :us_az => "Arizona", :us_ca => "California", :us_co => "Colorado", :us_ct => "Connecticut", :us_dc => "District of Columbia", :us_de => "Delaware", :us_fl => "Florida", :us_ga => "Georgia", :us_gu => "Guam", :us_hi => "Hawaii", :us_ia => "Iowa", :us_id => "Idaho", :us_il => "Illinois", :us_in => "Indiana", :us_ks => "Kansas", :us_ky => "Kentucky", :us_la => "Louisiana", :us_ma => "Massachusetts", :us_md => "Maryland", :us_me => "Maine", :us_mi => "Michigan", :us_mn => "Minnesota", :us_mo => "Missouri", :us_ms => "Mississippi", :us_mt => "Montana", :us_nc => "North Carolina", :us_nd => "North Dakota", :us_ne => "Nebraska", :us_nh => "New Hampshire", :us_nj => "New Jersey", :us_nm => "New Mexico", :us_nv => "Nevada", :us_ny => "New York", :us_oh => "Ohio", :us_ok => "Oklahoma", :us_or => "Oregon", :us_pa => "Pennsylvania", :us_pr => "Puerto Rico", :us_ri => "Rhode Island", :us_sc => "South Carolina", :us_sd => "South Dakota", :us_tn => "Tennessee", :us_tx => "Texas", :us_ut => "Utah", :us_va => "Virginia", :us_vi => "Virgin Islands, U.S.", :us_vt => "Vermont", :us_wa => "Washington", :us_wi => "Wisconsin", :us_wv => "West Virginia", :us_wy => "Wyoming", :unitednations => "United Nations", :ups => "UPS", :za => "South Africa", :ve => "Venezuela", :sk => "Slovakia", :si => "Slovenia", :jp => "Japan", :vn => "Vietnam", :sg => "Singapore", :my => "Malaysia", :th => "Thailand", :ng => "Nigeria"}
6
8
  end
@@ -383,8 +383,8 @@ module Holidays
383
383
  {:mday => 26, :observed => "to_monday_if_sunday(date)", :observed_arguments => [:date], :name => "San Esteban", :regions => [:es_ib, :es_ct]},
384
384
  {:mday => 25, :name => "Noël", :regions => [:fr]},
385
385
  {:mday => 26, :name => "Saint-Étienne", :regions => [:fr_a, :fr_m]},
386
- {:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:gb]},
387
- {:mday => 26, :observed => "to_weekday_if_boxing_weekend(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:gb]},
386
+ {:mday => 25, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:gb]},
387
+ {:mday => 26, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:gb]},
388
388
  {:mday => 25, :name => "Χριστούγεννα", :regions => [:gr]},
389
389
  {:mday => 26, :name => "Δεύτερη ημέρα των Χριστουγέννων", :regions => [:gr]},
390
390
  {:mday => 25, :name => "Božić", :regions => [:hr]},
@@ -37,8 +37,8 @@ module Holidays
37
37
  11 => [{:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]},
38
38
  {:mday => 30, :year_ranges => { :until => 2006 },:observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :type => :informal, :name => "St. Andrew's Day", :regions => [:gb_sct]},
39
39
  {:mday => 30, :year_ranges => { :from => 2007 },:observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "St. Andrew's Day", :regions => [:gb_sct]}],
40
- 12 => [{:mday => 25, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:gb]},
41
- {:mday => 26, :observed => "to_weekday_if_boxing_weekend(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:gb]}]
40
+ 12 => [{:mday => 25, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:gb]},
41
+ {:mday => 26, :observed => "to_tuesday_if_sunday_or_monday_if_saturday(date)", :observed_arguments => [:date], :name => "Boxing Day", :regions => [:gb]}]
42
42
  }
43
43
  end
44
44
 
@@ -35,11 +35,7 @@ module Holidays
35
35
  {
36
36
  "ph_heroes_day(year)" => Proc.new { |year|
37
37
  date = Date.new(year, 8, -1)
38
-
39
- if date.wday != 1
40
- date -= date.wday - 1
41
- end
42
-
38
+ date -= (date.wday - 1) % 7
43
39
  date
44
40
  },
45
41
 
@@ -27,6 +27,7 @@ module Holidays
27
27
  all_rules_by_month = {}
28
28
  all_custom_methods = {}
29
29
  all_tests = []
30
+ all_region_names = {}
30
31
 
31
32
  files.flatten!
32
33
 
@@ -51,11 +52,19 @@ module Holidays
51
52
  all_custom_methods.merge!(custom_methods)
52
53
 
53
54
  all_tests += @test_parser.call(definition_file['tests'])
55
+
56
+ region_names = definition_file['region_names']
57
+ if region_names
58
+ symbolized_region_names = region_names.each_with_object({}) do |(region, name), hash|
59
+ hash[region.to_sym] = name
60
+ end
61
+ all_region_names.merge!(symbolized_region_names)
62
+ end
54
63
  end
55
64
 
56
65
  all_regions.flatten!.uniq!
57
66
 
58
- [all_regions, all_rules_by_month, all_custom_methods, all_tests]
67
+ [all_regions, all_rules_by_month, all_custom_methods, all_tests, all_region_names]
59
68
  end
60
69
 
61
70
  def generate_definition_source(module_name, files, regions, rules_by_month, custom_methods, tests)
@@ -6,7 +6,7 @@ module Holidays
6
6
  # holiday definitions, but that does not make these countries subregions of one another.
7
7
  NORTH_AMERICA_REGIONS = %i[ca mx us].freeze
8
8
 
9
- def call(regions)
9
+ def call(regions, region_names = {})
10
10
  validate!(regions)
11
11
 
12
12
  <<-EOF
@@ -15,6 +15,8 @@ module Holidays
15
15
  REGIONS = #{to_array(regions)}
16
16
 
17
17
  PARENT_REGION_LOOKUP = #{generate_parent_lookup(regions)}
18
+
19
+ REGION_NAMES = #{generate_region_names(region_names)}
18
20
  end
19
21
  EOF
20
22
  end
@@ -50,6 +52,14 @@ EOF
50
52
  pairs = lookup.map { |k, v| "#{k}: :#{v}" }.join(", ")
51
53
  "{#{pairs}}"
52
54
  end
55
+
56
+ # Symbol keys and string values are emitted via inspect so the literal
57
+ # round-trips exactly: YAML-reserved keys like :no stay symbols and
58
+ # values with quotes or commas are escaped rather than breaking the hash.
59
+ def generate_region_names(region_names)
60
+ pairs = region_names.map { |sym, name| "#{sym.inspect} => #{name.inspect}" }.join(", ")
61
+ "{#{pairs}}"
62
+ end
53
63
  end
54
64
  end
55
65
  end
@@ -10,17 +10,19 @@ module Holidays
10
10
  raise ArgumentError unless cache_data
11
11
  raise ArgumentError unless start_date && end_date
12
12
 
13
- @cache_range[options] = start_date..end_date
14
- @cache[options] = cache_data.group_by { |holiday| holiday[:date] }
13
+ key = normalize(options)
14
+ @cache_range[key] = start_date..end_date
15
+ @cache[key] = cache_data.group_by { |holiday| holiday[:date] }
15
16
  end
16
17
 
17
18
  def find(start_date, end_date, options)
18
19
  return nil unless in_cache_range?(start_date, end_date, options)
19
20
 
21
+ key = normalize(options)
20
22
  if start_date == end_date
21
- @cache[options].fetch(start_date, [])
23
+ @cache[key].fetch(start_date, [])
22
24
  else
23
- @cache[options].select do |date, holidays|
25
+ @cache[key].select do |date, holidays|
24
26
  date >= start_date && date <= end_date
25
27
  end.flat_map { |date, holidays| holidays }
26
28
  end
@@ -33,8 +35,12 @@ module Holidays
33
35
 
34
36
  private
35
37
 
38
+ def normalize(options)
39
+ Array(options).flatten.map(&:to_sym).uniq.sort
40
+ end
41
+
36
42
  def in_cache_range?(start_date, end_date, options)
37
- range = @cache_range[options]
43
+ range = @cache_range[normalize(options)]
38
44
  if range
39
45
  range.begin <= start_date && range.end >= end_date
40
46
  else
@@ -1,3 +1,3 @@
1
1
  module Holidays
2
- VERSION = '11.0.0'
2
+ VERSION = '11.1.0'
3
3
  end
data/lib/holidays.rb CHANGED
@@ -89,8 +89,16 @@ module Holidays
89
89
  Holidays::REGIONS
90
90
  end
91
91
 
92
+ def region_names
93
+ Holidays::REGION_NAMES
94
+ end
95
+
96
+ def region_name(region)
97
+ Holidays::REGION_NAMES[region]
98
+ end
99
+
92
100
  def load_custom(*files)
93
- regions, rules_by_month, custom_methods, _ = Factory::Definition.file_parser.parse_definition_files(files)
101
+ regions, rules_by_month, custom_methods, _, _ = Factory::Definition.file_parser.parse_definition_files(files)
94
102
 
95
103
  # Capture source code before converting entities to Procs so the merger
96
104
  # can detect genuine conflicts (same name, different logic).
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holidays
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.0
4
+ version: 11.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae