line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- encoding: utf-8; indent-tabs-mode: nil -*- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Perl module to compute the French holidays in a given year. |
4
|
|
|
|
|
|
|
# Copyright © 2004, 2019 Fabien Potencier and Jean Forget, all rights reserved |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# See the license in the embedded documentation below. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
package Date::Holidays::FR; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
71730
|
use utf8; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
11
|
|
11
|
2
|
|
|
2
|
|
59
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
12
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
13
|
2
|
|
|
2
|
|
1033
|
use Time::Local; |
|
2
|
|
|
|
|
4683
|
|
|
2
|
|
|
|
|
131
|
|
14
|
2
|
|
|
2
|
|
923
|
use Date::Easter; |
|
2
|
|
|
|
|
1361
|
|
|
2
|
|
|
|
|
127
|
|
15
|
2
|
|
|
2
|
|
14
|
use Exporter; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1026
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
our @EXPORT = qw(is_fr_holiday); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_easter { |
22
|
60
|
|
|
60
|
1
|
92
|
my ($year) = @_; |
23
|
|
|
|
|
|
|
|
24
|
60
|
|
|
|
|
143
|
return Date::Easter::easter($year); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_ascension { |
28
|
1
|
|
|
1
|
1
|
1133
|
my ($year) = @_; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
5
|
return _compute_date_from_easter($year, 39); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_pentecost { |
34
|
1
|
|
|
1
|
1
|
1033
|
my ($year) = @_; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
5
|
return _compute_date_from_easter($year, 50); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _compute_date_from_easter { |
40
|
59
|
|
|
59
|
|
97
|
my ($year, $delta) = @_; |
41
|
|
|
|
|
|
|
|
42
|
59
|
|
|
|
|
102
|
my ($easter_month, $easter_day) = get_easter($year); |
43
|
59
|
|
|
|
|
1199
|
my $easter_date = Time::Local::timelocal(0, 0, 1, $easter_day, $easter_month - 1, $year - 1900); |
44
|
59
|
|
|
|
|
3847
|
my ($date_month, $date_day) = (localtime($easter_date + $delta * 86400))[4, 3]; |
45
|
59
|
|
|
|
|
139
|
$date_month++; |
46
|
|
|
|
|
|
|
|
47
|
59
|
|
|
|
|
132
|
return ($date_month, $date_day); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub is_fr_holiday { |
51
|
43
|
|
|
43
|
1
|
7360
|
my ($year, $month, $day) = @_; |
52
|
|
|
|
|
|
|
|
53
|
43
|
100
|
100
|
|
|
419
|
if ($day == 1 and $month == 1) { return "Nouvel an"; } |
|
3
|
100
|
100
|
|
|
17
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
54
|
3
|
|
|
|
|
23
|
elsif ($day == 1 and $month == 5) { return "Fête du travail"; } |
55
|
3
|
|
|
|
|
16
|
elsif ($day == 8 and $month == 5) { return "Armistice 1939-1945"; } |
56
|
3
|
|
|
|
|
18
|
elsif ($day == 14 and $month == 7) { return "Fête nationale"; } |
57
|
3
|
|
|
|
|
20
|
elsif ($day == 15 and $month == 8) { return "Assomption"; } |
58
|
3
|
|
|
|
|
14
|
elsif ($day == 1 and $month == 11) { return "Toussaint"; } |
59
|
3
|
|
|
|
|
14
|
elsif ($day == 11 and $month == 11) { return "Armistice 1914-1918"; } |
60
|
3
|
|
|
|
|
15
|
elsif ($day == 25 and $month == 12) { return "Noël"; } |
61
|
|
|
|
|
|
|
else { |
62
|
19
|
|
|
|
|
46
|
my ($easter_month, $easter_day) = _compute_date_from_easter($year, 1); |
63
|
19
|
|
|
|
|
53
|
my ($ascension_month, $ascension_day) = _compute_date_from_easter($year, 39); |
64
|
19
|
|
|
|
|
42
|
my ($pentecost_month, $pentecost_day) = _compute_date_from_easter($year, 50); |
65
|
|
|
|
|
|
|
|
66
|
19
|
100
|
66
|
|
|
181
|
if ($day == $easter_day and $month == $easter_month ) { return "Lundi de Pâques"; } |
|
4
|
100
|
66
|
|
|
33
|
|
|
|
100
|
66
|
|
|
|
|
67
|
3
|
|
|
|
|
23
|
elsif ($day == $ascension_day and $month == $ascension_month) { return "Ascension"; } |
68
|
3
|
|
|
|
|
22
|
elsif ($day == $pentecost_day and $month == $pentecost_month) { return "Lundi de Pentecôte"; } |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# And instead of a plain, boring "1" to end the module source, let us |
73
|
|
|
|
|
|
|
# celebrate the 14th of July, closely associated with the Bastille: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
"-- À la Bastille on l'aime bien Nini Peau-d'chien, |
76
|
|
|
|
|
|
|
Elle est si douce et si gentille ! |
77
|
|
|
|
|
|
|
On l'aime bien... |
78
|
|
|
|
|
|
|
-- QUI ÇA ? |
79
|
|
|
|
|
|
|
-- Nini Peau-d'chien... |
80
|
|
|
|
|
|
|
-- OÙ ÇA ? |
81
|
|
|
|
|
|
|
-- À la Basti-i-ille"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |