| 1 | package Date::Korean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use version; our $VERSION = qv('0.0.2'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use DateTime::Calendar::Julian; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Date::ISO8601 qw/cjdn_to_ymd/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Date::Korean::Table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our @EXPORT = qw/get_ganzi get_ganzi_ko sol2lun lun2sol/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | ▶ | sub _calculate_ganzi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_calculate_ganzi: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | my($year,$month,$day,$leap) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | my @ganzis = ( ($year+56)%60, ($year*12+$month+13)%60 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ($year,$month,$day) = lun2sol($year,$month,$day,$leap); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # mjd(Modified Julian Date) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | my $mjd = DateTime->new(year=>$year,month=>$month,day=>$day)->mjd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # solar 1582-10-15 -> mjd:-100840 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | ▶ | if ($mjd < -100840) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | $mjd += DateTime::Calendar::Julian | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ->new(year=>$year,month=>$month,day=>$day) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ->gregorian_deviation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 12 | push @ganzis, ($mjd+50)%60; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 12 | return @ganzis; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 12 | ▶ | sub get_ganzi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ganzi: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 12 | return map { $CELESTIAL_STEMS[$_%10].$TERRESTRIAL_BRANCHES[$_%12] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | _calculate_ganzi(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub get_ganzi_ko { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ganzi_ko: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return map { $CELESTIAL_STEMS_KO[$_%10].$TERRESTRIAL_BRANCHES_KO[$_%12] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | _calculate_ganzi(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 12 | ▶ | sub sol2lun { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sol2lun: called CC=14 SCAR=31.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 12 | my($year,$month,$day) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | my $days; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Chronological Julian Day(cjd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | $days = DateTime->new(year=>$year,month=>$month,day=>$day)->jd+0.5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | if ($@) { # Maybe valid Julian date. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ( $year<=1582 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $days = DateTime::Calendar::Julian | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ->new(year=>$year,month=>$month,day=>$day)->jd+0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | croak "Invalid date."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | croak "Invalid date."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # solar 1582-10-15 -> cjd:2299161 ,After this are gregorian calendar range. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 12 | ▶ | if ( $days < 2299161 ) { # julian calendar range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # gregorian 1582-10~05 ~ 1582-10-14 dates do not exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 6 | ▶ | if ( $year==1582 && $month==10 && $day>=5 && $day<=14) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$year == 1582 and $month == 10 and $day >= 5 and $day <= 14
$year == 1582 and $month == 10 and $day >= 5
$year == 1582 and $month == 10
MC/DC0%0/4
$year == 1582 and $month == 10 and $day >= 5 and $day <= 14
$year == 1582
$month == 10
$day >= 5
$day <= 14
Truth table40%2/5
A and B and C and D
A= $year == 1582B= $month == 10C= $day >= 5D= $day <= 14
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | croak "The gregorian date does not exist\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | $days = DateTime::Calendar::Julian | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ->new(year=>$year,month=>$month,day=>$day)->jd+0.5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | ▶ | if ( $days<$MINDATE || $days>$MAXDATE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$days < $Date::Korean::MINDATE or $days > $Date::Korean::MAXDATE
MC/DC0%0/2
$days < $Date::Korean::MINDATE or $days > $Date::Korean::MAXDATE
$days < $Date::Korean::MINDATE
$days > $Date::Korean::MAXDATE
Truth table33%1/3
A or B
A= $days < $Date::Korean::MINDATEB= $days > $Date::Korean::MAXDATE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | croak "The date is out of range." | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 12 | $days -= $MINDATE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 12 | $month = _bisect(\@MONTHTABLE,$days); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 12 | $year = _bisect(\@YEARTABLE,$month); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 12 | ($month,$day) = ( $month-$YEARTABLE[$year]+1, $days-$MONTHTABLE[$month]+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 12 | my $leap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | ▶ | if ( $LEAPTABLE[$year]!=0 && $LEAPTABLE[$year]<=$month ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Date::Korean::LEAPTABLE[$year] != 0 and $Date::Korean::LEAPTABLE[$year] <= $month
MC/DC100%2/2
$Date::Korean::LEAPTABLE[$year] != 0 and $Date::Korean::LEAPTABLE[$year] <= $month
$Date::Korean::LEAPTABLE[$year] != 0
$Date::Korean::LEAPTABLE[$year] <= $month
Truth table100%3/3
A and B
A= $Date::Korean::LEAPTABLE[$year] != 0B= $Date::Korean::LEAPTABLE[$year] <= $month
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | ▶ | if ( $LEAPTABLE[$year] == $month ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | $leap = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | $leap = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 6 | $month -= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 6 | $leap = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 12 | return ( $year+$BASEYEAR, $month, $day, $leap ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | ▶ | sub lun2sol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lun2sol: called CC=14 SCAR=29.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 24 | my($year,$month,$day,$leap) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 24 | $year -= $BASEYEAR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 24 | ▶ | unless ( $year>=0 && $year< $#YEARTABLE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$year >= 0 and $year < $#Date::Korean::YEARTABLE
MC/DC0%0/2
$year >= 0 and $year < $#Date::Korean::YEARTABLE
$year >= 0
$year < $#Date::Korean::YEARTABLE
Truth table33%1/3
A and B
A= $year >= 0B= $year < $#Date::Korean::YEARTABLE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | croak "Year is out of range."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 24 | ▶ | unless ( $month>=1 && $month <=12 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$month >= 1 and $month <= 12
MC/DC0%0/2
$month >= 1 and $month <= 12
$month >= 1
$month <= 12
Truth table33%1/3
A and B
A= $month >= 1B= $month <= 12
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | croak "Month is out of range."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 24 | ▶ | if ( $leap!=0 && ($LEAPTABLE[$year]-1)!=$month ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$leap != 0 and $Date::Korean::LEAPTABLE[$year] - 1 != $month
MC/DC0%0/2
$leap != 0 and $Date::Korean::LEAPTABLE[$year] - 1 != $month
$leap != 0
$Date::Korean::LEAPTABLE[$year] - 1 != $month
Truth table66%2/3
A and B
A= $leap != 0B= $Date::Korean::LEAPTABLE[$year] - 1 != $month
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | croak "Wrong leap month."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 24 | my $months = $YEARTABLE[$year] + $month - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 24 | ▶ | if ( $leap==1 && ($month+1)==$LEAPTABLE[$year] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$leap == 1 and $month + 1 == $Date::Korean::LEAPTABLE[$year]
MC/DC50%1/2
$leap == 1 and $month + 1 == $Date::Korean::LEAPTABLE[$year]
$leap == 1
$month + 1 == $Date::Korean::LEAPTABLE[$year]
Truth table66%2/3
A and B
A= $leap == 1B= $month + 1 == $Date::Korean::LEAPTABLE[$year]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | $months += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ▶ | elsif ( $LEAPTABLE[$year]!=0 && $LEAPTABLE[$year]<=$month ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$Date::Korean::LEAPTABLE[$year] != 0 and $Date::Korean::LEAPTABLE[$year] <= $month
MC/DC100%2/2
$Date::Korean::LEAPTABLE[$year] != 0 and $Date::Korean::LEAPTABLE[$year] <= $month
$Date::Korean::LEAPTABLE[$year] != 0
$Date::Korean::LEAPTABLE[$year] <= $month
Truth table100%3/3
A and B
A= $Date::Korean::LEAPTABLE[$year] != 0B= $Date::Korean::LEAPTABLE[$year] <= $month
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | $months += 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 24 | my $days = $MONTHTABLE[$months] + $day -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 24 | ▶ | if ( $day<1 || $days>=$MONTHTABLE[$months+1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$day < 1 or $days >= $Date::Korean::MONTHTABLE[$months + 1]
MC/DC0%0/2
$day < 1 or $days >= $Date::Korean::MONTHTABLE[$months + 1]
$day < 1
$days >= $Date::Korean::MONTHTABLE[$months + 1]
Truth table33%1/3
A or B
A= $day < 1B= $days >= $Date::Korean::MONTHTABLE[$months + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | croak "Wrong day."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # 1582-10-15 -> cjd(chronical julian date):2299161 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 24 | ▶ | if ( ($days+$MINDATE) < 2299161 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 12 | my ($y,$m,$d) = cjdn_to_ymd($days+$MINDATE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 12 | my $deviation = DateTime::Calendar::Julian | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ->new(year=>$y,month=>$m,day=>$d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ->gregorian_deviation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 12 | return cjdn_to_ymd($days+$MINDATE-$deviation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 12 | return cjdn_to_ymd($days+$MINDATE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 24 | ▶ | sub _bisect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bisect: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 24 | my ($a,$x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 24 | my $lo = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 24 | my $hi = $#{$a}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 24 | ▶ | while ( $lo < $hi ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 270 | my $mid = int( ($lo+$hi)/2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 270 | ▶ | if ( $x < $a->[$mid] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 176 | $hi = $mid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 94 | $lo = $mid + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 24 | return $lo-1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||