| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Date::Holidays::AT; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20112
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Stock modules |
|
7
|
1
|
|
|
1
|
|
805
|
use Time::Local; |
|
|
1
|
|
|
|
|
1556
|
|
|
|
1
|
|
|
|
|
87
|
|
|
8
|
1
|
|
|
1
|
|
712
|
use POSIX qw(strftime); |
|
|
1
|
|
|
|
|
6422
|
|
|
|
1
|
|
|
|
|
6
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Prerequisite |
|
11
|
1
|
|
|
1
|
|
1783
|
use Date::Calc 5.0 qw(Add_Delta_Days Easter_Sunday Day_of_Week This_Year); |
|
|
1
|
|
|
|
|
33907
|
|
|
|
1
|
|
|
|
|
157
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw(holidays); |
|
17
|
1
|
|
|
1
|
|
1030
|
use version; our $VERSION = qv("0.1.3"); |
|
|
1
|
|
|
|
|
2301
|
|
|
|
1
|
|
|
|
|
7
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub holidays { |
|
20
|
0
|
|
|
0
|
0
|
|
my %parameters = ( |
|
21
|
|
|
|
|
|
|
YEAR => This_Year(), |
|
22
|
|
|
|
|
|
|
FORMAT => "%s", |
|
23
|
|
|
|
|
|
|
WEEKENDS => 1, |
|
24
|
|
|
|
|
|
|
@_, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Easter is the key to everything |
|
28
|
0
|
|
|
|
|
|
my ($year, $month, $day) = Easter_Sunday($parameters{'YEAR'}); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Aliases for holidays |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
# neuj = New year's day |
|
33
|
|
|
|
|
|
|
# hl3k = Heilige 3 Koenige |
|
34
|
|
|
|
|
|
|
# jose = Josef |
|
35
|
|
|
|
|
|
|
# tdar = Staatsfeiertag (Tag der Arbeit) |
|
36
|
|
|
|
|
|
|
# flor = Florian |
|
37
|
|
|
|
|
|
|
# mahi = Mariae Himmelfahrt |
|
38
|
|
|
|
|
|
|
# rupe = Rupert |
|
39
|
|
|
|
|
|
|
# volk = Tag der Volksabstimmung |
|
40
|
|
|
|
|
|
|
# nati = Nationalfeiertag |
|
41
|
|
|
|
|
|
|
# alhe = Allerheiligen |
|
42
|
|
|
|
|
|
|
# mart = Martin |
|
43
|
|
|
|
|
|
|
# leop = Leopold |
|
44
|
|
|
|
|
|
|
# maem = Mariae Empfaengnis |
|
45
|
|
|
|
|
|
|
# heab = Heiliger Abend |
|
46
|
|
|
|
|
|
|
# chri = Christtag |
|
47
|
|
|
|
|
|
|
# stef = Stefanitag |
|
48
|
|
|
|
|
|
|
# silv = Silvester |
|
49
|
|
|
|
|
|
|
# karf = Karfreitag |
|
50
|
|
|
|
|
|
|
# ostm = Ostermontag |
|
51
|
|
|
|
|
|
|
# himm = Christi Himmelfahrt |
|
52
|
|
|
|
|
|
|
# pfim = Pfingstmontag |
|
53
|
|
|
|
|
|
|
# fron = Fronleichnam |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Fixed-date holidays |
|
56
|
|
|
|
|
|
|
# |
|
57
|
0
|
|
|
|
|
|
my (%holiday, %holidays); |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$holiday{'neuj'} = _date2timestamp($year, 1, 1); # New year's day |
|
60
|
0
|
|
|
|
|
|
$holiday{'hl3k'} = _date2timestamp($year, 1, 6); # Heilige 3 Koenige |
|
61
|
0
|
|
|
|
|
|
$holiday{'jose'} = _date2timestamp($year, 3, 19); # Josef |
|
62
|
0
|
|
|
|
|
|
$holiday{'tdar'} = _date2timestamp($year, 5, 1); # Staatsfeiertag (Tag der Arbeit) |
|
63
|
0
|
|
|
|
|
|
$holiday{'flor'} = _date2timestamp($year, 5, 4); # Florian |
|
64
|
0
|
|
|
|
|
|
$holiday{'mahi'} = _date2timestamp($year, 8, 15); # Mariae Himmelfahrt |
|
65
|
0
|
|
|
|
|
|
$holiday{'rupe'} = _date2timestamp($year, 9, 24); # Rupert |
|
66
|
0
|
|
|
|
|
|
$holiday{'volk'} = _date2timestamp($year, 10, 10); # Tag der Volksabstimmung |
|
67
|
0
|
|
|
|
|
|
$holiday{'nati'} = _date2timestamp($year, 10, 26); # Nationalfeiertag |
|
68
|
0
|
|
|
|
|
|
$holiday{'alhe'} = _date2timestamp($year, 11, 1); # Allerheiligen |
|
69
|
0
|
|
|
|
|
|
$holiday{'mart'} = _date2timestamp($year, 11, 11); # Martin |
|
70
|
0
|
|
|
|
|
|
$holiday{'leop'} = _date2timestamp($year, 11, 15); # Leopold |
|
71
|
0
|
|
|
|
|
|
$holiday{'maem'} = _date2timestamp($year, 12, 8); # Mariae Empfaengnis |
|
72
|
0
|
|
|
|
|
|
$holiday{'heab'} = _date2timestamp($year, 12, 24); # Heiliger Abend |
|
73
|
0
|
|
|
|
|
|
$holiday{'chri'} = _date2timestamp($year, 12, 25); # Christtag |
|
74
|
0
|
|
|
|
|
|
$holiday{'stef'} = _date2timestamp($year, 12, 26); # Stefanitag |
|
75
|
0
|
|
|
|
|
|
$holiday{'silv'} = _date2timestamp($year, 12, 31); # Silvester |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Holidays relative to Easter |
|
78
|
|
|
|
|
|
|
# |
|
79
|
|
|
|
|
|
|
# Karfreitag (Good Friday) = Easter Sunday minus 2 days |
|
80
|
0
|
|
|
|
|
|
my ($j_karf, $m_karf, $t_karf) = Date::Calc::Add_Delta_Days($year, $month, $day, -2); |
|
81
|
0
|
|
|
|
|
|
$holiday{'karf'} = _date2timestamp($j_karf, $m_karf, $t_karf); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Ostermontag (Easter Monday) = Easter Sunday plus 1 day |
|
84
|
0
|
|
|
|
|
|
my ($j_ostm, $m_ostm, $t_ostm) = Date::Calc::Add_Delta_Days($year, $month, $day, 1); |
|
85
|
0
|
|
|
|
|
|
$holiday{'ostm'} = _date2timestamp($j_ostm, $m_ostm, $t_ostm); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Christi Himmelfahrt (Ascension Day) = Easter Sunday plus 39 days |
|
88
|
0
|
|
|
|
|
|
my ($j_himm, $m_himm, $t_himm) = Date::Calc::Add_Delta_Days($year, $month, $day, 39); |
|
89
|
0
|
|
|
|
|
|
$holiday{'himm'} = _date2timestamp($j_himm, $m_himm, $t_himm); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Pfingsmontag (Whit Monday) = Easter Sunday plus 50 days |
|
92
|
0
|
|
|
|
|
|
my ($j_pfim, $m_pfim, $t_pfim) = Date::Calc::Add_Delta_Days($year, $month, $day, 50); |
|
93
|
0
|
|
|
|
|
|
$holiday{'pfim'} = _date2timestamp($j_pfim, $m_pfim, $t_pfim); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Fronleichnam (Corpus Christi) = Easter Sunday plus 60 days |
|
96
|
0
|
|
|
|
|
|
my ($j_fron, $m_fron, $t_fron) = Date::Calc::Add_Delta_Days($year, $month, $day, 60); |
|
97
|
0
|
|
|
|
|
|
$holiday{'fron'} = _date2timestamp($j_fron, $m_fron, $t_fron); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Common holidays througout Austria |
|
100
|
0
|
|
|
|
|
|
@{ $holidays{'common'} } = qw(neuj hl3k tdar mahi nati alhe mart maem chri stef); |
|
|
0
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Build list for returning |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Add the most obscure holidays that were requested through |
|
106
|
|
|
|
|
|
|
# the ADD parameter |
|
107
|
0
|
0
|
|
|
|
|
if ($parameters{'ADD'}) { |
|
108
|
0
|
|
|
|
|
|
foreach my $add (@{ $parameters{'ADD'} }) { |
|
|
0
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$holiday{$add} = $holiday{$add}; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# If WEEKENDS => 0 was passed, weed out holidays on weekends |
|
114
|
|
|
|
|
|
|
# |
|
115
|
0
|
0
|
|
|
|
|
unless (1 == $parameters{'WEEKENDS'}) { |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Walk the list of holidays |
|
118
|
0
|
|
|
|
|
|
foreach my $alias (keys(%holiday)) { |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Get day of week. Since we're no longer |
|
121
|
|
|
|
|
|
|
# in Date::Calc's world, use localtime() |
|
122
|
0
|
|
|
|
|
|
my $dow = (localtime($holiday{$alias}))[6]; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# dow 6 = Saturday, dow 0 = Sunday |
|
125
|
0
|
0
|
0
|
|
|
|
if ((6 == $dow) or (0 == $dow)) { |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Kick this day from the list |
|
128
|
0
|
|
|
|
|
|
delete $holiday{$alias}; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Sort values stored in the hash for returning |
|
134
|
|
|
|
|
|
|
# |
|
135
|
0
|
|
|
|
|
|
my @returnlist; |
|
136
|
0
|
|
|
|
|
|
foreach (sort { $holiday{$a} <=> $holiday{$b} } (keys(%holiday))) { |
|
|
0
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# See if this platform has strftime(%s) |
|
139
|
|
|
|
|
|
|
# if not, inject seconds manually into format string. |
|
140
|
0
|
|
|
|
|
|
my $formatstring = $parameters{'FORMAT'}; |
|
141
|
0
|
0
|
|
|
|
|
if (strftime('%s', localtime($holiday{$_})) eq '%s') { |
|
142
|
0
|
|
|
|
|
|
$formatstring =~ s/%{0}%s/$holiday{$_}/g; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Inject the holiday's alias name into the format string |
|
146
|
|
|
|
|
|
|
# if it was requested by adding %#. |
|
147
|
0
|
|
|
|
|
|
$formatstring =~ s/%{0}%#/$_/; |
|
148
|
0
|
|
|
|
|
|
push @returnlist, strftime($formatstring, localtime($holiday{$_})); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
0
|
|
|
|
|
|
return \@returnlist; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub _date2timestamp { |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Turn Date::Calc's y/m/d format into a UNIX timestamp |
|
156
|
0
|
|
|
0
|
|
|
my ($y, $m, $d) = @_; |
|
157
|
0
|
|
|
|
|
|
my $timestamp = timelocal(0, 0, 0, $d, ($m - 1), $y); |
|
158
|
0
|
|
|
|
|
|
return $timestamp; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
|
162
|
|
|
|
|
|
|
__END__ |