Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #25 from lecterror/master

added Croatian holidays + a small bugfix. That duplicated Europe entry appeared in 3c0c38f. I suppose it was a unintentional merge on git's part.
  • Loading branch information...
commit c3dbba0070b5c31a536c2d13bb83ed74449e4e24 2 parents 1d90e4d + 8a9d48f
@hahahana hahahana authored
View
77 data/hr.yaml
@@ -0,0 +1,77 @@
+# Croatian holiday definitions for the Ruby Holiday gem.
+#
+# Updated: 2012-08-29.
+# Sources:
+# http://en.wikipedia.org/wiki/Public_holidays_in_Croatia
+---
+months:
+ 0:
+ - name: Uskrs
+ regions: [hr]
+ function: easter(year)
+ - name: Uskrsni ponedjeljak
+ regions: [hr]
+ function: easter(year)+1
+ - name: Tijelovo
+ regions: [hr]
+ function: easter(year)+60
+ 1:
+ - name: Nova godina
+ regions: [hr]
+ mday: 1
+ - name: Sveta tri kralja
+ regions: [hr]
+ mday: 6
+ 5:
+ - name: Međunarodni praznik rada
+ regions: [hr]
+ mday: 1
+ 6:
+ - name: Dan antifašističke borbe
+ regions: [hr]
+ mday: 22
+ - name: Dan državnosti
+ regions: [hr]
+ mday: 25
+ 8:
+ - name: Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja
+ regions: [hr]
+ mday: 5
+ - name: Velika Gospa
+ regions: [hr]
+ mday: 15
+ 10:
+ - name: Dan neovisnosti
+ regions: [hr]
+ mday: 8
+ 11:
+ - name: Dan svih svetih
+ regions: [hr]
+ mday: 1
+ 12:
+ - name: Božić
+ regions: [hr]
+ mday: 25
+ - name: Sveti Stjepan
+ regions: [hr]
+ mday: 26
+tests: |
+ {Date.civil(2012,1,1) => 'Nova godina',
+ Date.civil(2012,1,6) => 'Sveta tri kralja',
+ Date.civil(2012,5,1) => 'Međunarodni praznik rada',
+ Date.civil(2012,6,22) => 'Dan antifašističke borbe',
+ Date.civil(2012,6,25) => 'Dan državnosti',
+ Date.civil(2012,8,5) => 'Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja',
+ Date.civil(2012,8,15) => 'Velika Gospa',
+ Date.civil(2012,10,8) => 'Dan neovisnosti',
+ Date.civil(2012,11,1) => 'Dan svih svetih',
+ Date.civil(2012,12,25) => 'Božić',
+ Date.civil(2012,12,26) => 'Sveti Stjepan'}.each do |date, name|
+ assert_equal name, (Holidays.on(date, :hr, :informal)[0] || {})[:name]
+ end
+
+ # Tijelovo
+ [Date.civil(2008,5,22), Date.civil(2009,6,11), Date.civil(2010,6,3),
+ Date.civil(2012,6,7), Date.civil(2013,5,30), Date.civil(2014,6,19)].each do |date|
+ assert_equal 'Tijelovo', Holidays.on(date, :hr)[0][:name]
+ end
View
4 data/index.yaml
@@ -15,6 +15,7 @@ defs:
FI: ['fi.yaml']
FR: ['fr.yaml']
GB: ['gb.yaml']
+ HR: ['hr.yaml']
HU: ['hu.yaml']
IE: ['ie.yaml']
IS: ['is.yaml']
@@ -34,6 +35,5 @@ defs:
ZA: ['za.yaml']
North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
Scandinavia: ['dk.yaml', 'is.yaml', 'no.yaml', 'se.yaml', 'fi.yaml']
- Europe: ['at.yaml', 'ch.yaml', 'cz.yaml', 'dk.yaml', 'de.yaml', 'el.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'hu.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'li.yaml', 'nl.yaml', 'no.yaml', 'pl.yaml', 'pt.yaml']
- Europe: ['at.yaml', 'ch.yaml', 'cz.yaml', 'dk.yaml', 'de.yaml', 'el.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'hu.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'li.yaml', 'nl.yaml', 'no.yaml', 'pl.yaml', 'pt.yaml']
+ Europe: ['at.yaml', 'ch.yaml', 'cz.yaml', 'dk.yaml', 'de.yaml', 'el.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'hr.yaml', 'hu.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'li.yaml', 'nl.yaml', 'no.yaml', 'pl.yaml', 'pt.yaml']
JP: ['jp.yaml']
View
18 lib/holidays/europe.rb
@@ -2,7 +2,7 @@
module Holidays
# This file is generated by the Ruby Holidays gem.
#
- # Definitions loaded: data/at.yaml, data/ch.yaml, data/cz.yaml, data/dk.yaml, data/de.yaml, data/el.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/hu.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/li.yaml, data/nl.yaml, data/no.yaml, data/pl.yaml, data/pt.yaml
+ # Definitions loaded: data/at.yaml, data/ch.yaml, data/cz.yaml, data/dk.yaml, data/de.yaml, data/el.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/hr.yaml, data/hu.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/li.yaml, data/nl.yaml, data/no.yaml, data/pl.yaml, data/pt.yaml
#
# To use the definitions in this file, load it right after you load the
# Holiday gem:
@@ -13,7 +13,7 @@ module Holidays
# All the definitions are available at https://github.com/alexdunae/holidays
module Europe # :nodoc:
def self.defined_regions
- [:at, :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_vs, :ch_ge, :ch_ju, :de, :li, :ch_ne, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :ch, :cz, :dk, :no, :de_bb, :de_mv, :de_sn, :de_th, :el, :es_pv, :es_ct, :es_na, :es_v, :es_vc, :es, :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, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hu, :is, :it, :nl, :pl, :pt]
+ [:at, :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_vs, :ch_ge, :ch_ju, :de, :li, :ch_ne, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :ch, :cz, :dk, :no, :de_bb, :de_mv, :de_sn, :de_th, :el, :es_pv, :es_ct, :es_na, :es_v, :es_vc, :es, :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, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :is, :it, :nl, :pl, :pt]
end
def self.holidays_by_month
@@ -54,6 +54,9 @@ def self.holidays_by_month
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:gb]},
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:gb]},
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie]},
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Uskrs", :regions => [:hr]},
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Uskrsni ponedjeljak", :regions => [:hr]},
+ {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Tijelovo", :regions => [:hr]},
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Húsvét hétfő", :regions => [:hu]},
{:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pünkösd hétfő", :regions => [:hu]},
{:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]},
@@ -108,6 +111,8 @@ def self.holidays_by_month
{:mday => 1, :name => "Jour de l'an", :regions => [:fr]},
{:mday => 1, :name => "New Year's Day", :regions => [:gb]},
{:mday => 2, :name => "New Year's", :regions => [:gb_sct]},
+ {:mday => 1, :name => "Nova godina", :regions => [:hr]},
+ {:mday => 6, :name => "Sveta tri kralja", :regions => [:hr]},
{:mday => 1, :name => "Újév", :regions => [:hu]},
{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "New Year's Day", :regions => [:ie]},
{:mday => 1, :name => "Nýársdagur", :regions => [:is]},
@@ -139,6 +144,7 @@ def self.holidays_by_month
{:wday => 1, :week => 1, :name => "May Day", :regions => [:gb, :ie]},
{:mday => 9, :name => "Liberation Day", :regions => [:je, :gb_jsy, :gg, :gb_gsy]},
{:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb]},
+ {:mday => 1, :name => "Međunarodni praznik rada", :regions => [:hr]},
{:mday => 1, :name => "A munka ünnepe", :regions => [:hu]},
{:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]},
{:mday => 13, :name => "Mæðradagurinn", :regions => [:is]},
@@ -158,6 +164,8 @@ def self.holidays_by_month
{:mday => 15, :name => "Assomption", :regions => [:fr]},
{:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct]},
{:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]},
+ {:mday => 5, :name => "Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja", :regions => [:hr]},
+ {:mday => 15, :name => "Velika Gospa", :regions => [:hr]},
{:mday => 20, :name => "Az államalapítás ünnepe", :regions => [:hu]},
{:wday => 1, :week => 1, :name => "August Bank Holiday", :regions => [:ie]},
{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]},
@@ -172,6 +180,7 @@ def self.holidays_by_month
{:mday => 28, :name => "Επέτειος του Όχι", :regions => [:el]},
{:mday => 9, :name => "Día de Valencia", :regions => [:es_vc, :es_v]},
{:mday => 12, :name => "Día de la Hispanidad", :regions => [:es]},
+ {:mday => 8, :name => "Dan neovisnosti", :regions => [:hr]},
{:mday => 23, :name => "1956-os forradalom és szabadságharc ünnepe", :regions => [:hu]},
{:wday => 1, :week => -1, :name => "October Bank Holiday", :regions => [:ie]},
{:mday => 14, :type => :informal, :name => "Dzień Nauczyciela (Dzień Edukacji Narodowej)", :regions => [:pl]}],
@@ -183,6 +192,7 @@ def self.holidays_by_month
{:mday => 1, :name => "Toussaint", :regions => [:fr]},
{:mday => 11, :name => "Armistice 1918", :regions => [:fr]},
{:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]},
+ {:mday => 1, :name => "Dan svih svetih", :regions => [:hr]},
{:mday => 1, :name => "Mindenszentek", :regions => [:hu]},
{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]},
{:mday => 1, :name => "Ognissanti", :regions => [:it]},
@@ -214,6 +224,8 @@ def self.holidays_by_month
{:mday => 25, :name => "Nöel", :regions => [:fr]},
{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:gb, :ie]},
{:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:gb]},
+ {:mday => 25, :name => "Božić", :regions => [:hr]},
+ {:mday => 26, :name => "Sveti Stjepan", :regions => [:hr]},
{:mday => 25, :name => "Karácsony", :regions => [:hu]},
{:mday => 26, :name => "Karácsony", :regions => [:hu]},
{:mday => 26, :observed => lambda { |date| Holidays.ie_st_stephens_day(date) }, :observed_id => "ie_st_stephens_day", :name => "St. Stephen's Day", :regions => [:ie]},
@@ -270,6 +282,8 @@ def self.holidays_by_month
{:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]},
{:mday => 9, :name => "Día de la Región de Murcia", :regions => [:es_mu]},
{:mday => 9, :name => "Día de La Rioja", :regions => [:es_lo]},
+ {:mday => 22, :name => "Dan antifašističke borbe", :regions => [:hr]},
+ {:mday => 25, :name => "Dan državnosti", :regions => [:hr]},
{:wday => 1, :week => 1, :name => "June Bank Holiday", :regions => [:ie]},
{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
{:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]},
View
42 lib/holidays/hr.rb
@@ -0,0 +1,42 @@
+# encoding: utf-8
+module Holidays
+ # This file is generated by the Ruby Holidays gem.
+ #
+ # Definitions loaded: data/hr.yaml
+ #
+ # To use the definitions in this file, load it right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'holidays/hr'
+ #
+ # All the definitions are available at https://github.com/alexdunae/holidays
+ module HR # :nodoc:
+ def self.defined_regions
+ [:hr]
+ end
+
+ def self.holidays_by_month
+ {
+ 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Uskrs", :regions => [:hr]},
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Uskrsni ponedjeljak", :regions => [:hr]},
+ {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Tijelovo", :regions => [:hr]}],
+ 1 => [{:mday => 1, :name => "Nova godina", :regions => [:hr]},
+ {:mday => 6, :name => "Sveta tri kralja", :regions => [:hr]}],
+ 5 => [{:mday => 1, :name => "Međunarodni praznik rada", :regions => [:hr]}],
+ 6 => [{:mday => 22, :name => "Dan antifašističke borbe", :regions => [:hr]},
+ {:mday => 25, :name => "Dan državnosti", :regions => [:hr]}],
+ 8 => [{:mday => 5, :name => "Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja", :regions => [:hr]},
+ {:mday => 15, :name => "Velika Gospa", :regions => [:hr]}],
+ 10 => [{:mday => 8, :name => "Dan neovisnosti", :regions => [:hr]}],
+ 11 => [{:mday => 1, :name => "Dan svih svetih", :regions => [:hr]}],
+ 12 => [{:mday => 25, :name => "Božić", :regions => [:hr]},
+ {:mday => 26, :name => "Sveti Stjepan", :regions => [:hr]}]
+ }
+ end
+ end
+
+
+end
+
+Holidays.merge_defs(Holidays::HR.defined_regions, Holidays::HR.holidays_by_month)
View
23 test/defs/test_defs_europe.rb
@@ -3,7 +3,7 @@
# This file is generated by the Ruby Holiday gem.
#
-# Definitions loaded: data/at.yaml, data/ch.yaml, data/cz.yaml, data/dk.yaml, data/de.yaml, data/el.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/hu.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/li.yaml, data/nl.yaml, data/no.yaml, data/pl.yaml, data/pt.yaml
+# Definitions loaded: data/at.yaml, data/ch.yaml, data/cz.yaml, data/dk.yaml, data/de.yaml, data/el.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/hr.yaml, data/hu.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/li.yaml, data/nl.yaml, data/no.yaml, data/pl.yaml, data/pt.yaml
class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
def test_europe
@@ -233,6 +233,27 @@ def test_europe
assert_equal 'Bank Holiday', Date.civil(2008,8,25).holidays(r)[0][:name]
end
+{Date.civil(2012,1,1) => 'Nova godina',
+ Date.civil(2012,1,6) => 'Sveta tri kralja',
+ Date.civil(2012,5,1) => 'Međunarodni praznik rada',
+ Date.civil(2012,6,22) => 'Dan antifašističke borbe',
+ Date.civil(2012,6,25) => 'Dan državnosti',
+ Date.civil(2012,8,5) => 'Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja',
+ Date.civil(2012,8,15) => 'Velika Gospa',
+ Date.civil(2012,10,8) => 'Dan neovisnosti',
+ Date.civil(2012,11,1) => 'Dan svih svetih',
+ Date.civil(2012,12,25) => 'Božić',
+ Date.civil(2012,12,26) => 'Sveti Stjepan'}.each do |date, name|
+ assert_equal name, (Holidays.on(date, :hr, :informal)[0] || {})[:name]
+end
+
+# Tijelovo
+[Date.civil(2008,5,22), Date.civil(2009,6,11), Date.civil(2010,6,3),
+ Date.civil(2012,6,7), Date.civil(2013,5,30), Date.civil(2014,6,19)].each do |date|
+ assert_equal 'Tijelovo', Holidays.on(date, :hr)[0][:name]
+end
+
+
{Date.civil(2012,1,1) => 'Újév',
Date.civil(2011,1,1) => 'Újév',
Date.civil(2012,3,15) => '1848/49-es forradalom és szabadságharc ünnepe',
View
31 test/defs/test_defs_hr.rb
@@ -0,0 +1,31 @@
+# encoding: utf-8
+require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
+
+# This file is generated by the Ruby Holiday gem.
+#
+# Definitions loaded: data/hr.yaml
+class HrDefinitionTests < Test::Unit::TestCase # :nodoc:
+
+ def test_hr
+{Date.civil(2012,1,1) => 'Nova godina',
+ Date.civil(2012,1,6) => 'Sveta tri kralja',
+ Date.civil(2012,5,1) => 'Međunarodni praznik rada',
+ Date.civil(2012,6,22) => 'Dan antifašističke borbe',
+ Date.civil(2012,6,25) => 'Dan državnosti',
+ Date.civil(2012,8,5) => 'Dan pobjede i domovinske zahvalnosti i dan hrvatskih branitelja',
+ Date.civil(2012,8,15) => 'Velika Gospa',
+ Date.civil(2012,10,8) => 'Dan neovisnosti',
+ Date.civil(2012,11,1) => 'Dan svih svetih',
+ Date.civil(2012,12,25) => 'Božić',
+ Date.civil(2012,12,26) => 'Sveti Stjepan'}.each do |date, name|
+ assert_equal name, (Holidays.on(date, :hr, :informal)[0] || {})[:name]
+end
+
+# Tijelovo
+[Date.civil(2008,5,22), Date.civil(2009,6,11), Date.civil(2010,6,3),
+ Date.civil(2012,6,7), Date.civil(2013,5,30), Date.civil(2014,6,19)].each do |date|
+ assert_equal 'Tijelovo', Holidays.on(date, :hr)[0][:name]
+end
+
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.