line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Holidays::KR; |
2
|
4
|
|
|
4
|
|
264503
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
104
|
|
3
|
4
|
|
|
4
|
|
51
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
110
|
|
4
|
4
|
|
|
4
|
|
19
|
use base 'Exporter'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
337
|
|
5
|
4
|
|
|
4
|
|
2825
|
use Date::Korean; |
|
4
|
|
|
|
|
354601
|
|
|
4
|
|
|
|
|
327
|
|
6
|
4
|
|
|
4
|
|
55
|
use DateTime; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
89
|
|
7
|
4
|
|
|
4
|
|
20
|
use Try::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
3026
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
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
|
|
|
|
|
|
|
'1009' => '한글날', |
21
|
|
|
|
|
|
|
'1225' => '크리스마스', |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $LUNAR = { |
25
|
|
|
|
|
|
|
'1229' => '설앞날', |
26
|
|
|
|
|
|
|
'1230' => '설앞날', |
27
|
|
|
|
|
|
|
'0101' => '설날', |
28
|
|
|
|
|
|
|
'0102' => '설뒷날', |
29
|
|
|
|
|
|
|
'0408' => '부처님오신날', |
30
|
|
|
|
|
|
|
'0814' => '추석앞날', |
31
|
|
|
|
|
|
|
'0815' => '추석', |
32
|
|
|
|
|
|
|
'0816' => '추석뒷날', |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub is_solar_holiday { |
36
|
80
|
|
|
80
|
0
|
122
|
my ($year, $month, $day) = @_; |
37
|
80
|
50
|
|
|
|
182
|
defined $year || return; |
38
|
80
|
50
|
|
|
|
153
|
defined $month || return; |
39
|
80
|
50
|
|
|
|
153
|
defined $day || return; |
40
|
80
|
|
|
|
|
462
|
return $SOLAR->{sprintf '%02d%02d', $month, $day}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub is_lunar_holiday { |
44
|
77
|
|
|
77
|
0
|
110
|
my ($year, $month, $day) = @_; |
45
|
77
|
50
|
|
|
|
151
|
defined $year || return; |
46
|
77
|
50
|
|
|
|
136
|
defined $month || return; |
47
|
77
|
50
|
|
|
|
148
|
defined $day || return; |
48
|
|
|
|
|
|
|
|
49
|
77
|
|
|
|
|
210
|
my ($ly, $lm, $ld, $leap) = sol2lun($year, $month, $day); |
50
|
|
|
|
|
|
|
|
51
|
77
|
|
|
|
|
22797
|
my $flag = _check_korean_new_year($year, $lm, $ld, $month, $day); |
52
|
77
|
50
|
|
|
|
172
|
return if $flag; |
53
|
77
|
|
|
|
|
570
|
return $LUNAR->{sprintf '%02d%02d', $lm, $ld}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub is_holiday { |
57
|
80
|
100
|
|
80
|
1
|
110159
|
is_solar_holiday(@_) || is_lunar_holiday(@_); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub holidays { |
61
|
24
|
|
|
24
|
1
|
14996
|
my ($year) = @_; |
62
|
24
|
50
|
|
|
|
57
|
defined $year || return; |
63
|
|
|
|
|
|
|
|
64
|
24
|
|
|
|
|
142
|
my $holidays = { %$SOLAR }; |
65
|
|
|
|
|
|
|
|
66
|
24
|
|
|
|
|
80
|
for my $_year ( ($year - 1) .. $year ) { |
67
|
48
|
|
|
|
|
128
|
for my $date ( keys %$LUNAR ) { |
68
|
384
|
|
|
|
|
1353
|
my ($lm, $ld) = $date =~ /^(\d\d)(\d\d)$/; |
69
|
|
|
|
|
|
|
|
70
|
384
|
|
|
|
|
617
|
$lm = int $lm; |
71
|
384
|
|
|
|
|
418
|
$ld = int $ld; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my ( $y, $m, $d ) = |
74
|
384
|
|
|
384
|
|
9400
|
try { lun2sol($_year, $lm, $ld, 1) } |
75
|
|
|
|
|
|
|
catch { |
76
|
376
|
|
|
|
|
9115
|
try { lun2sol($_year, $lm, $ld, 0) } |
77
|
376
|
|
|
376
|
|
50294
|
catch { () }; |
|
18
|
|
|
|
|
2408
|
|
78
|
384
|
|
|
|
|
2015
|
}; |
79
|
|
|
|
|
|
|
|
80
|
384
|
100
|
|
|
|
26060
|
next unless $y; |
81
|
366
|
100
|
|
|
|
968
|
next unless $y eq $year; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# |
84
|
|
|
|
|
|
|
# check Korean New Year |
85
|
|
|
|
|
|
|
# |
86
|
183
|
|
|
|
|
357
|
my $flag = _check_korean_new_year($year, $lm, $ld, $m, $d); |
87
|
183
|
100
|
|
|
|
412
|
next if $flag; |
88
|
168
|
|
|
|
|
733
|
$holidays->{sprintf '%02d%02d', $m, $d} = $LUNAR->{$date}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
24
|
|
|
|
|
58
|
$holidays; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _check_korean_new_year { |
96
|
260
|
|
|
260
|
|
421
|
my ($y,$lm, $ld, $m, $d) = @_; |
97
|
|
|
|
|
|
|
|
98
|
260
|
100
|
100
|
|
|
804
|
if ( $lm == 12 && $ld == 29 ) { |
99
|
34
|
|
|
|
|
131
|
my $dt = DateTime->new( |
100
|
|
|
|
|
|
|
year => $y, |
101
|
|
|
|
|
|
|
month => $m, |
102
|
|
|
|
|
|
|
day => $d, |
103
|
|
|
|
|
|
|
)->add( days => 1 ); |
104
|
|
|
|
|
|
|
|
105
|
34
|
|
|
|
|
24667
|
my ( $ly2, $lm2, $ld2 ) = sol2lun($dt->year, $dt->month, $dt->day); |
106
|
|
|
|
|
|
|
|
107
|
34
|
100
|
66
|
|
|
9968
|
return 1 if $lm2 == 12 && $ld2 == 30; |
108
|
|
|
|
|
|
|
} |
109
|
245
|
|
|
|
|
396
|
return 0; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |