| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Date::Holidays::KR; |
|
2
|
4
|
|
|
4
|
|
441550
|
use strict; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
132
|
|
|
3
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
116
|
|
|
4
|
4
|
|
|
4
|
|
22
|
use base 'Exporter'; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
362
|
|
|
5
|
4
|
|
|
4
|
|
3693
|
use Date::Korean; |
|
|
4
|
|
|
|
|
704386
|
|
|
|
4
|
|
|
|
|
277
|
|
|
6
|
4
|
|
|
4
|
|
47
|
use DateTime; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
81
|
|
|
7
|
4
|
|
|
4
|
|
29
|
use Try::Tiny; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
3345
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw/is_holiday holidays/; |
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw/is_solar_holiday is_lunar_holiday/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $SOLAR = { |
|
14
|
|
|
|
|
|
|
'0101' => '신정', |
|
15
|
|
|
|
|
|
|
'0301' => '삼일절', |
|
16
|
|
|
|
|
|
|
'0505' => '어린이날', |
|
17
|
|
|
|
|
|
|
'0606' => '현충일', |
|
18
|
|
|
|
|
|
|
'0815' => '광복절', |
|
19
|
|
|
|
|
|
|
'1003' => '개천절', |
|
20
|
|
|
|
|
|
|
'1225' => '크리스마스', |
|
21
|
|
|
|
|
|
|
}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $LUNAR = { |
|
24
|
|
|
|
|
|
|
'1229' => '설앞날', |
|
25
|
|
|
|
|
|
|
'1230' => '설앞날', |
|
26
|
|
|
|
|
|
|
'0101' => '설날', |
|
27
|
|
|
|
|
|
|
'0102' => '설뒷날', |
|
28
|
|
|
|
|
|
|
'0408' => '부처님오신날', |
|
29
|
|
|
|
|
|
|
'0814' => '추석앞날', |
|
30
|
|
|
|
|
|
|
'0815' => '추석', |
|
31
|
|
|
|
|
|
|
'0816' => '추석뒷날', |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_solar_holiday { |
|
35
|
80
|
|
|
80
|
0
|
132
|
my ($year, $month, $day) = @_; |
|
36
|
80
|
50
|
|
|
|
213
|
defined $year || return; |
|
37
|
80
|
50
|
|
|
|
152
|
defined $month || return; |
|
38
|
80
|
50
|
|
|
|
172
|
defined $day || return; |
|
39
|
80
|
|
|
|
|
505
|
return $SOLAR->{sprintf '%02d%02d', $month, $day}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub is_lunar_holiday { |
|
43
|
77
|
|
|
77
|
0
|
112
|
my ($year, $month, $day) = @_; |
|
44
|
77
|
50
|
|
|
|
215
|
defined $year || return; |
|
45
|
77
|
50
|
|
|
|
134
|
defined $month || return; |
|
46
|
77
|
50
|
|
|
|
141
|
defined $day || return; |
|
47
|
|
|
|
|
|
|
|
|
48
|
77
|
|
|
|
|
261
|
my ($ly, $lm, $ld, $leap) = sol2lun($year, $month, $day); |
|
49
|
|
|
|
|
|
|
|
|
50
|
77
|
|
|
|
|
24625
|
my $flag = _check_korean_new_year($year, $lm, $ld, $month, $day); |
|
51
|
77
|
50
|
|
|
|
156
|
return if $flag; |
|
52
|
77
|
|
|
|
|
655
|
return $LUNAR->{sprintf '%02d%02d', $lm, $ld}; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub is_holiday { |
|
56
|
80
|
100
|
|
80
|
1
|
158147
|
is_solar_holiday(@_) || is_lunar_holiday(@_); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub holidays { |
|
60
|
24
|
|
|
24
|
1
|
17849
|
my ($year) = @_; |
|
61
|
24
|
50
|
|
|
|
68
|
defined $year || return; |
|
62
|
|
|
|
|
|
|
|
|
63
|
24
|
|
|
|
|
113
|
my $holidays = { %$SOLAR }; |
|
64
|
|
|
|
|
|
|
|
|
65
|
24
|
|
|
|
|
77
|
for my $_year ( ($year - 1) .. $year ) { |
|
66
|
48
|
|
|
|
|
107
|
for my $date ( keys %$LUNAR ) { |
|
67
|
384
|
|
|
|
|
1242
|
my ($lm, $ld) = $date =~ /^(\d\d)(\d\d)$/; |
|
68
|
|
|
|
|
|
|
|
|
69
|
384
|
|
|
|
|
515
|
$lm = int $lm; |
|
70
|
384
|
|
|
|
|
367
|
$ld = int $ld; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my ( $y, $m, $d ) = |
|
73
|
384
|
|
|
384
|
|
8702
|
try { lun2sol($_year, $lm, $ld, 1) } |
|
74
|
|
|
|
|
|
|
catch { |
|
75
|
376
|
|
|
|
|
8421
|
try { lun2sol($_year, $lm, $ld, 0) } |
|
76
|
376
|
|
|
376
|
|
50702
|
catch { () }; |
|
|
18
|
|
|
|
|
2237
|
|
|
77
|
384
|
|
|
|
|
2087
|
}; |
|
78
|
|
|
|
|
|
|
|
|
79
|
384
|
100
|
|
|
|
24211
|
next unless $y; |
|
80
|
366
|
100
|
|
|
|
907
|
next unless $y eq $year; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# |
|
83
|
|
|
|
|
|
|
# check Korean New Year |
|
84
|
|
|
|
|
|
|
# |
|
85
|
183
|
|
|
|
|
321
|
my $flag = _check_korean_new_year($year, $lm, $ld, $m, $d); |
|
86
|
183
|
100
|
|
|
|
348
|
next if $flag; |
|
87
|
168
|
|
|
|
|
689
|
$holidays->{sprintf '%02d%02d', $m, $d} = $LUNAR->{$date}; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
24
|
|
|
|
|
70
|
$holidays; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _check_korean_new_year { |
|
95
|
260
|
|
|
260
|
|
403
|
my ($y,$lm, $ld, $m, $d) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
260
|
100
|
100
|
|
|
806
|
if ( $lm == 12 && $ld == 29 ) { |
|
98
|
34
|
|
|
|
|
142
|
my $dt = DateTime->new( |
|
99
|
|
|
|
|
|
|
year => $y, |
|
100
|
|
|
|
|
|
|
month => $m, |
|
101
|
|
|
|
|
|
|
day => $d, |
|
102
|
|
|
|
|
|
|
)->add( days => 1 ); |
|
103
|
|
|
|
|
|
|
|
|
104
|
34
|
|
|
|
|
26291
|
my ( $ly2, $lm2, $ld2 ) = sol2lun($dt->year, $dt->month, $dt->day); |
|
105
|
|
|
|
|
|
|
|
|
106
|
34
|
100
|
66
|
|
|
9893
|
return 1 if $lm2 == 12 && $ld2 == 30; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
245
|
|
|
|
|
356
|
return 0; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
__END__ |