feriados 2.1.1 → 3.0.1
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 +4 -4
- data/lib/feriados/argentina.rb +38 -32
- data/lib/feriados.rb +28 -30
- data/test/{test_date.rb → date_test.rb} +28 -22
- data/test/{helper.rb → test_helper.rb} +0 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 132b8e4a800c3cb3a2e24eccb914eef054ad152d
|
4
|
+
data.tar.gz: 2bf6ba574acd5cba5fefa4c1dc63f5633731a578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf269e31c1861050e8aadc51d4fddb7aba389415fa222aa82d7efb7cbbcf1dc5a8c63d21c3f1b54e73a3db169aa4427952faa69e2af34d3ef22ed761989aec0
|
7
|
+
data.tar.gz: d2d1c2da3df0cccd210fa9c355284d0950d19cdac84b2353e6f3c3495ce28718a44eb0239e78593d063177daa0451a7705a3faa7bc8d029fceb0b1dc1b014726
|
data/lib/feriados/argentina.rb
CHANGED
@@ -1,61 +1,67 @@
|
|
1
|
-
#encoding:
|
1
|
+
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Feriados
|
4
4
|
module Argentina
|
5
5
|
# Feriados Fijos
|
6
6
|
Feriados.add 'Año nuevo', day: 1, month: 1
|
7
7
|
Feriados.add 'Día Nacional de la Memoria por la Verdad y la Justicia',
|
8
|
-
|
8
|
+
day: 24, month: 3
|
9
9
|
Feriados.add 'Día del Veterano y de los Caídos en la Guerra de Malvinas',
|
10
|
-
|
10
|
+
day: 2, month: 4
|
11
11
|
Feriados.add 'Día del trabajador', day: 1, month: 5
|
12
12
|
Feriados.add 'Día de la Revolución de Mayo', day: 25, month: 5
|
13
|
-
Feriados.add 'Paso a la Inmortalidad del General Manuel Belgrano',
|
14
|
-
|
13
|
+
Feriados.add 'Paso a la Inmortalidad del General Manuel Belgrano',
|
14
|
+
day: 20, month: 6
|
15
15
|
Feriados.add 'Día de la Independencia', day: 9, month: 7
|
16
16
|
Feriados.add 'Inmaculada Concepción de María', day: 8, month: 12
|
17
17
|
Feriados.add 'Navidad', day: 25, month: 12
|
18
18
|
|
19
19
|
# Feriados calculados
|
20
|
-
Feriados.add 'easter', function: ->(year) { Feriados.easter(year) }
|
21
|
-
Feriados.add 'Viernes Santo',
|
22
|
-
|
23
|
-
Feriados.add '
|
24
|
-
|
20
|
+
Feriados.add 'easter', function: -> (year) { Feriados.easter(year) }
|
21
|
+
Feriados.add 'Viernes Santo',
|
22
|
+
function: -> (year) { Feriados.easter(year) - 2 }
|
23
|
+
Feriados.add 'Jueves Santo',
|
24
|
+
function: -> (year) { Feriados.easter(year) - 3 }
|
25
|
+
Feriados.add 'Lunes de Carnaval',
|
26
|
+
function: -> (year) { Feriados.easter(year) - 48 }
|
27
|
+
Feriados.add 'Martes de Carnaval',
|
28
|
+
function: -> (year) { Feriados.easter(year) - 47 }
|
25
29
|
|
26
30
|
# Feriados relativos
|
27
31
|
Feriados.add 'Paso a la Inmortalidad del General José de San Martín',
|
28
|
-
|
29
|
-
Feriados.add 'Día del Respeto a la Diversidad Cultural',
|
30
|
-
|
31
|
-
Feriados.add 'Día de la Soberanía Nacional',
|
32
|
-
|
32
|
+
day: 17, month: 8, fix_change: [:third, :monday]
|
33
|
+
Feriados.add 'Día del Respeto a la Diversidad Cultural',
|
34
|
+
day: 12, month: 10, fix_change: [:second, :monday]
|
35
|
+
Feriados.add 'Día de la Soberanía Nacional',
|
36
|
+
day: 20, month: 11, fix_change: [:fourth, :monday]
|
33
37
|
|
34
38
|
# Feriados especiales 2012
|
35
|
-
Feriados.add
|
36
|
-
Bandera Argentina
|
37
|
-
Feriados.add
|
38
|
-
|
39
|
-
Feriados.add
|
40
|
-
Feriados.add
|
39
|
+
Feriados.add 'Día del Bicentenario de la Creación y Primera Jura de la'\
|
40
|
+
'Bandera Argentina', day: 27, month: 2, year: 2012
|
41
|
+
Feriados.add 'Día del Bicentenario de la Batalla de Tucumán',
|
42
|
+
day: 24, month: 9, year: 2012
|
43
|
+
Feriados.add 'Feriado puente', day: 30, month: 4, year: 2012
|
44
|
+
Feriados.add 'Feriado puente', day: 24, month: 12, year: 2012
|
41
45
|
|
42
46
|
# Feriados especiales 2013
|
43
|
-
Feriados.add
|
44
|
-
|
45
|
-
Feriados.add
|
46
|
-
Feriados.add
|
47
|
-
Feriados.add
|
47
|
+
Feriados.add 'Bicentenario de la Asamblea General Constituyente de 1813',
|
48
|
+
day: 31, month: 1, year: 2013
|
49
|
+
Feriados.add 'Día de la Batalla de Salta', day: 20, month: 2, year: 2013
|
50
|
+
Feriados.add 'Feriado puente', day: 1, month: 4, year: 2013
|
51
|
+
Feriados.add 'Feriado puente', day: 21, month: 6, year: 2013
|
48
52
|
|
49
53
|
# Feriados especiales 2014
|
50
|
-
Feriados.add
|
51
|
-
Feriados.add
|
54
|
+
Feriados.add 'Feriado puente', day: 2, month: 5, year: 2014
|
55
|
+
Feriados.add 'Feriado puente', day: 26, month: 12, year: 2014
|
52
56
|
|
53
57
|
# Feriados especiales 2015
|
54
|
-
Feriados.add
|
55
|
-
Feriados.add
|
58
|
+
Feriados.add 'Feriado puente', day: 23, month: 3, year: 2015
|
59
|
+
Feriados.add 'Bicentenario del Congreso de los Pueblos Libres',
|
60
|
+
day: 29, month: 6, year: 2015
|
61
|
+
Feriados.add 'Feriado puente', day: 7, month: 12, year: 2015
|
56
62
|
|
57
63
|
# Feriados especiales 2016
|
58
|
-
Feriados.add
|
59
|
-
Feriados.add
|
64
|
+
Feriados.add 'Feriado puente', day: 8, month: 7, year: 2016
|
65
|
+
Feriados.add 'Feriado puente', day: 9, month: 12, year: 2016
|
60
66
|
end
|
61
67
|
end
|
data/lib/feriados.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
3
|
module Feriados
|
4
|
-
DAYS = {sunday: 7, monday: 1, tuesday: 2, wednesday: 3, thursday: 4,
|
5
|
-
|
4
|
+
DAYS = { sunday: 7, monday: 1, tuesday: 2, wednesday: 3, thursday: 4,
|
5
|
+
friday: 5, saturday: 6 }
|
6
6
|
|
7
7
|
def self.add(description, options = {})
|
8
|
-
@holidays_by_month ||= {}
|
9
8
|
month = options[:month] || 0
|
9
|
+
@holidays_by_month ||= {}
|
10
10
|
@holidays_by_month[month] ||= []
|
11
|
-
@holidays_by_month[month] << {description: description}.merge!(options)
|
11
|
+
@holidays_by_month[month] << { description: description }.merge!(options)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.calculated(th, day, month, year)
|
15
|
-
n = {first: 1, second: 2, third: 3, fourth: 4}
|
15
|
+
n = { first: 1, second: 2, third: 3, fourth: 4 }
|
16
16
|
|
17
17
|
week = n[th]
|
18
18
|
date = Date.civil(year, month, 1)
|
@@ -23,10 +23,9 @@ module Feriados
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.easter(year)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
c = y % 100
|
26
|
+
a = year % 19
|
27
|
+
b = year / 100
|
28
|
+
c = year % 100
|
30
29
|
d = b / 4
|
31
30
|
e = b % 4
|
32
31
|
f = (b + 8) / 25
|
@@ -38,6 +37,7 @@ module Feriados
|
|
38
37
|
m = (a + 11 * h + 22 * l) / 451
|
39
38
|
month = (h + l - 7 * m + 114) / 31
|
40
39
|
day = ((h + l - 7 * m + 114) % 31) + 1
|
40
|
+
|
41
41
|
Date.civil(year, month, day)
|
42
42
|
end
|
43
43
|
|
@@ -53,25 +53,23 @@ module Feriados
|
|
53
53
|
|
54
54
|
dates.each do |year, months|
|
55
55
|
months.each do |month|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
56
|
+
next unless (holidays = @holidays_by_month[month])
|
57
|
+
holidays.each do |holiday|
|
58
|
+
description = holiday[:description]
|
59
|
+
date = if holiday[:function]
|
60
|
+
holiday[:function].call(year)
|
61
|
+
elsif holiday[:fix_change]
|
62
|
+
calculated(holiday[:fix_change][0], holiday[:fix_change][1],
|
63
|
+
month, year)
|
64
|
+
elsif holiday[:variable_change]
|
65
|
+
holiday[:variable_change].call(Date.civil(year, month,
|
66
|
+
holiday[:day]))
|
67
|
+
else
|
68
|
+
Date.civil(holiday[:year] || year, month, holiday[:day])
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
end
|
71
|
+
if date.between?(start_date, end_date) && date.year == year
|
72
|
+
list << { date: date, description: description }
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
@@ -82,12 +80,12 @@ module Feriados
|
|
82
80
|
end
|
83
81
|
|
84
82
|
class Date
|
85
|
-
def
|
83
|
+
def holiday?
|
86
84
|
holidays = Feriados.between(self, self)
|
87
85
|
holidays && !holidays.empty?
|
88
86
|
end
|
89
87
|
|
90
|
-
def
|
91
|
-
|
88
|
+
def week_end?
|
89
|
+
wday == 6 || wday == 0
|
92
90
|
end
|
93
91
|
end
|
@@ -1,30 +1,24 @@
|
|
1
|
-
#encoding:
|
1
|
+
# encoding: UTF-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper.rb'
|
4
4
|
|
5
5
|
class DateTests < MiniTest::Test
|
6
|
-
def setup
|
7
|
-
@date = Date.civil(2012,1,1)
|
8
|
-
end
|
9
|
-
|
10
6
|
def test_extending_date_class
|
11
|
-
|
12
|
-
|
7
|
+
@date = Date.civil(2012, 1, 1)
|
8
|
+
|
9
|
+
assert @date.respond_to?('holiday?')
|
10
|
+
assert @date.respond_to?('week_end?')
|
13
11
|
end
|
14
12
|
|
15
13
|
def test_week_end
|
16
|
-
regulars = [ :monday, :tuesday, :wednesday, :thursday, :friday ]
|
17
|
-
week_end = [ :saturday, :sunday ]
|
18
|
-
nths = [ :first, :second, :third, :fourth ]
|
19
|
-
|
20
14
|
(2012..2015).each do |year|
|
21
15
|
(1..12).each do |month|
|
22
16
|
nths.each do |n|
|
23
17
|
regulars.each do |day|
|
24
|
-
|
18
|
+
refute Feriados.calculated(n, day, month, year).week_end?
|
25
19
|
end
|
26
20
|
week_end.each do |day|
|
27
|
-
assert Feriados.calculated(n, day, month, year).
|
21
|
+
assert Feriados.calculated(n, day, month, year).week_end?
|
28
22
|
end
|
29
23
|
end
|
30
24
|
end
|
@@ -32,7 +26,7 @@ class DateTests < MiniTest::Test
|
|
32
26
|
end
|
33
27
|
|
34
28
|
def test_calculated
|
35
|
-
#
|
29
|
+
# Dia de la bandera.
|
36
30
|
assert_equal 18, Feriados.calculated(:third, :monday, 6, 2012).day
|
37
31
|
assert_equal 17, Feriados.calculated(:third, :monday, 6, 2013).day
|
38
32
|
assert_equal 16, Feriados.calculated(:third, :monday, 6, 2014).day
|
@@ -62,13 +56,25 @@ class DateTests < MiniTest::Test
|
|
62
56
|
|
63
57
|
def test_fix_holidays
|
64
58
|
2012.upto(2015) do |year|
|
65
|
-
assert Date.civil(year, 1, 1).
|
66
|
-
assert Date.civil(year, 3, 24).
|
67
|
-
assert Date.civil(year, 4, 2).
|
68
|
-
assert Date.civil(year, 5, 1).
|
69
|
-
assert Date.civil(year, 7, 9).
|
70
|
-
assert Date.civil(year, 12, 8).
|
71
|
-
assert Date.civil(year, 12, 25).
|
59
|
+
assert Date.civil(year, 1, 1).holiday?
|
60
|
+
assert Date.civil(year, 3, 24).holiday?
|
61
|
+
assert Date.civil(year, 4, 2).holiday?
|
62
|
+
assert Date.civil(year, 5, 1).holiday?
|
63
|
+
assert Date.civil(year, 7, 9).holiday?
|
64
|
+
assert Date.civil(year, 12, 8).holiday?
|
65
|
+
assert Date.civil(year, 12, 25).holiday?
|
72
66
|
end
|
73
67
|
end
|
68
|
+
|
69
|
+
def regulars
|
70
|
+
[:monday, :tuesday, :wednesday, :thursday, :friday]
|
71
|
+
end
|
72
|
+
|
73
|
+
def week_end
|
74
|
+
[:saturday, :sunday]
|
75
|
+
end
|
76
|
+
|
77
|
+
def nths
|
78
|
+
[:first, :second, :third, :fourth]
|
79
|
+
end
|
74
80
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feriados
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Rabuini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Feriados argentinos. Adaptable to other countries
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- lib/feriados.rb
|
21
21
|
- lib/feriados/argentina.rb
|
22
|
-
- test/
|
23
|
-
- test/
|
22
|
+
- test/date_test.rb
|
23
|
+
- test/test_helper.rb
|
24
24
|
homepage: https://github.com/srabuini/feriados
|
25
25
|
licenses:
|
26
26
|
- MIT
|
@@ -41,11 +41,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.4.
|
44
|
+
rubygems_version: 2.4.5
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: Feriados argentinos
|
48
48
|
test_files:
|
49
|
-
- test/
|
50
|
-
- test/
|
49
|
+
- test/date_test.rb
|
50
|
+
- test/test_helper.rb
|
51
51
|
has_rdoc:
|