Permalink
Browse files

merging venezuelan holidays

  • Loading branch information...
2 parents c3dbba0 + d42ca99 commit 0a6163b63ded83676cb23f11ff5857cb1a9c58b6 @hahahana hahahana committed Mar 12, 2013
Showing with 164 additions and 24 deletions.
  1. +1 −0 data/index.yaml
  2. +70 −0 data/ve.yaml
  3. +25 −24 lib/holidays/MANIFEST
  4. +40 −0 lib/holidays/ve.rb
  5. +28 −0 test/defs/test_defs_ve.rb
View
@@ -37,3 +37,4 @@ defs:
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', 'hr.yaml', 'hu.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'li.yaml', 'nl.yaml', 'no.yaml', 'pl.yaml', 'pt.yaml']
JP: ['jp.yaml']
+ VE: ['ve.yaml']
View
@@ -0,0 +1,70 @@
+# Venezuela holiday definitions for the Ruby Holiday gem.
+#
+# Just including nonworking days nationally
+#
+# Updated: 2012-09-14.
+# Source: http://venciclopedia.com/index.php?title=D%C3%ADas_feriados_de_Venezuela
+---
+months:
+ 0:
+ - name: Lunes Carnaval
+ regions: [ve]
+ function: easter(year)-48
+ - name: Martes Carnaval
+ regions: [ve]
+ function: easter(year)-47
+ - name: Jueves Santo
+ regions: [ve]
+ function: easter(year)-3
+ - name: Viernes Santo
+ regions: [ve]
+ function: easter(year)-2
+ 1:
+ - name: Año Nuevo
+ regions: [ve]
+ mday: 1
+ 4:
+ - name: Declaración Independencia
+ regions: [ve]
+ mday: 19
+ 5:
+ - name: Día del Trabajador
+ regions: [ve]
+ mday: 1
+ 6:
+ - name: Aniversario Batalla de Carabobo
+ regions: [ve]
+ mday: 24
+ 7:
+ - name: Día de la Independencia
+ regions: [ve]
+ mday: 5
+ - name: Natalicio de Simón Bolívar
+ regions: [ve]
+ mday: 24
+ 10:
+ - name: Día de la Resistencia Indígena
+ regions: [ve]
+ mday: 12
+ 12:
+ - name: Día de Navidad
+ regions: [ve]
+ mday: 25
+
+tests: |
+ {
+ Date.civil(2013, 1, 1) => "Año Nuevo",
+ Date.civil(2013, 2, 11) => "Lunes Carnaval",
+ Date.civil(2013, 2, 12) => "Martes Carnaval",
+ Date.civil(2013, 3, 28) => "Jueves Santo",
+ Date.civil(2013, 3, 29) => "Viernes Santo",
+ Date.civil(2013, 4, 19) => "Declaración Independencia",
+ Date.civil(2013, 5, 1) => "Día del Trabajador",
+ Date.civil(2013, 6, 24) => "Aniversario Batalla de Carabobo",
+ Date.civil(2013, 7, 5) => "Día de la Independencia",
+ Date.civil(2013, 7, 24) => "Natalicio de Simón Bolívar",
+ Date.civil(2013, 10, 12) => "Día de la Resistencia Indígena",
+ Date.civil(2013, 12, 25) => "Día de Navidad"
+ }.each do |date, name|
+ assert_equal name, (Holidays.on(date, :ve)[0] || {})[:name]
+ end
View
@@ -1,37 +1,38 @@
==== Regional definitions
The following definition files are included in this installation:
-* holidays/is
-* holidays/nyse
-* holidays/us
-* holidays/nz
-* holidays/united_nations
-* holidays/pl
-* holidays/se
+* holidays/za
* holidays/it
-* holidays/at
-* holidays/no
-* holidays/fr
+* holidays/gb
+* holidays/nyse
+* holidays/dk
* holidays/cz
-* holidays/el
-* holidays/north_america
-* holidays/europe
-* holidays/jp
-* holidays/au
-* holidays/ca
-* holidays/de
* holidays/ch
+* holidays/ca
+* holidays/is
+* holidays/el
* holidays/hu
* holidays/ups
+* holidays/europe
+* holidays/scandinavia
+* holidays/ve
+* holidays/at
+* holidays/nl
+* holidays/pt
+* holidays/br
+* holidays/pl
* holidays/fi
+* holidays/de
* holidays/es
+* holidays/united_nations
+* holidays/se
+* holidays/jp
* holidays/mx
+* holidays/nz
+* holidays/no
* holidays/li
-* holidays/gb
* holidays/ie
-* holidays/nl
-* holidays/scandinavia
-* holidays/pt
-* holidays/za
-* holidays/br
-* holidays/dk
+* holidays/north_america
+* holidays/us
+* holidays/au
+* holidays/fr
View
@@ -0,0 +1,40 @@
+# encoding: utf-8
+module Holidays
+ # This file is generated by the Ruby Holidays gem.
+ #
+ # Definitions loaded: data/ve.yaml
+ #
+ # To use the definitions in this file, load it right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'holidays/ve'
+ #
+ # All the definitions are available at https://github.com/alexdunae/holidays
+ module VE # :nodoc:
+ def self.defined_regions
+ [:ve]
+ end
+
+ def self.holidays_by_month
+ {
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Lunes Carnaval", :regions => [:ve]},
+ {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Martes Carnaval", :regions => [:ve]},
+ {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Jueves Santo", :regions => [:ve]},
+ {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Viernes Santo", :regions => [:ve]}],
+ 1 => [{:mday => 1, :name => "Año Nuevo", :regions => [:ve]}],
+ 4 => [{:mday => 19, :name => "Declaración Independencia", :regions => [:ve]}],
+ 5 => [{:mday => 1, :name => "Día del Trabajador", :regions => [:ve]}],
+ 6 => [{:mday => 24, :name => "Aniversario Batalla de Carabobo", :regions => [:ve]}],
+ 7 => [{:mday => 5, :name => "Día de la Independencia", :regions => [:ve]},
+ {:mday => 24, :name => "Natalicio de Simón Bolívar", :regions => [:ve]}],
+ 10 => [{:mday => 12, :name => "Día de la Resistencia Indígena", :regions => [:ve]}],
+ 12 => [{:mday => 25, :name => "Día de Navidad", :regions => [:ve]}]
+ }
+ end
+ end
+
+
+end
+
+Holidays.merge_defs(Holidays::VE.defined_regions, Holidays::VE.holidays_by_month)
@@ -0,0 +1,28 @@
+# encoding: utf-8
+require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
+
+# This file is generated by the Ruby Holiday gem.
+#
+# Definitions loaded: data/ve.yaml
+class VeDefinitionTests < Test::Unit::TestCase # :nodoc:
+
+ def test_ve
+{
+Date.civil(2013, 1, 1) => "Año Nuevo",
+Date.civil(2013, 2, 11) => "Lunes Carnaval",
+Date.civil(2013, 2, 12) => "Martes Carnaval",
+Date.civil(2013, 3, 28) => "Jueves Santo",
+Date.civil(2013, 3, 29) => "Viernes Santo",
+Date.civil(2013, 4, 19) => "Declaración Independencia",
+Date.civil(2013, 5, 1) => "Día del Trabajador",
+Date.civil(2013, 6, 24) => "Aniversario Batalla de Carabobo",
+Date.civil(2013, 7, 5) => "Día de la Independencia",
+Date.civil(2013, 7, 24) => "Natalicio de Simón Bolívar",
+Date.civil(2013, 10, 12) => "Día de la Resistencia Indígena",
+Date.civil(2013, 12, 25) => "Día de Navidad"
+}.each do |date, name|
+ assert_equal name, (Holidays.on(date, :ve)[0] || {})[:name]
+end
+
+ end
+end

0 comments on commit 0a6163b

Please sign in to comment.