mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-05 08:20:23 +00:00
Erwin removed the need for DateTime::Event::Easter
git-svn-id: https://svn.fhem.de/fhem/trunk@1066 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
bc3fed3618
commit
d0efec225e
@ -1,4 +1,6 @@
|
|||||||
|
### mh changed 95_holiday.pm to 95_holiday_MH.pm
|
||||||
|
### mh no requirement for DateTime::Event::Easter
|
||||||
|
### mh
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@ -76,18 +78,28 @@ holiday_refresh($$)
|
|||||||
|
|
||||||
} elsif($l =~ m/^2/) { # Easter date: 2 +1 Ostermontag
|
} elsif($l =~ m/^2/) { # Easter date: 2 +1 Ostermontag
|
||||||
|
|
||||||
eval { require DateTime::Event::Easter } ;
|
###mh new code for easter sunday calc w.o. requirement for
|
||||||
if( $@) {
|
# DateTime::Event::Easter
|
||||||
Log 1, "$@";
|
# replace $a1 with $1 !!!
|
||||||
|
# split line from file into args '2 <offset from E-sunday> <tagname>'
|
||||||
|
my @a = split(" ", $l, 3);
|
||||||
|
|
||||||
} else {
|
# get month & day for E-sunday
|
||||||
my @a = split(" +", $l, 3);
|
my ($Om,$Od) = western_easter(($lt[5]+1900));
|
||||||
my $dt = DateTime::Event::Easter->new(day=>$a[1])
|
my $timex = mktime(0,0,12,$Od,$Om-1, $lt[5],0,0,-1); # gen timevalue
|
||||||
->following(DateTime->new(year=>(1900+$lt[5])));
|
$timex = $timex + $a[1]*86400; # add offset days
|
||||||
next if($dt->day != $fd[3] || $dt->month != $fd[4]+1);
|
|
||||||
$found = $a[2];
|
my ($msecond, $mminute, $mhour,
|
||||||
last;
|
$mday, $mmonth, $myear, $mrest) = localtime($timex);
|
||||||
}
|
$myear = $myear+1900;
|
||||||
|
$mmonth = $mmonth+1;
|
||||||
|
#Log 4, "$name: Ostern ".($lt[5]+1900)." ist am " .sprintf("%02d-%02d",
|
||||||
|
# $Od, $Om) ." Target day: $mday-$mmonth-$myear";
|
||||||
|
|
||||||
|
next if($mday != $fd[3] || $mmonth != $fd[4]+1);
|
||||||
|
$found = $a[2];
|
||||||
|
Log 4, "$name: Match day: $a[2]\n";
|
||||||
|
last;
|
||||||
|
|
||||||
} elsif($l =~ m/^3/) { # Relative date: 3 -1 Mon 03 Holiday
|
} elsif($l =~ m/^3/) { # Relative date: 3 -1 Mon 03 Holiday
|
||||||
my @a = split(" +", $l, 5);
|
my @a = split(" +", $l, 5);
|
||||||
@ -200,4 +212,32 @@ schaltjahr($)
|
|||||||
return 1; # 2012
|
return 1; # 2012
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### mh sub western_easter copied from cpan Date::Time::Easter
|
||||||
|
### mh changes marked with # mh
|
||||||
|
### mh
|
||||||
|
### mh calling parameter is 4 digit year
|
||||||
|
### mh
|
||||||
|
sub
|
||||||
|
western_easter($)
|
||||||
|
{
|
||||||
|
my $year = shift;
|
||||||
|
my $golden_number = $year % 19;
|
||||||
|
|
||||||
|
#quasicentury is so named because its a century, only its
|
||||||
|
# the number of full centuries rather than the current century
|
||||||
|
my $quasicentury = int($year / 100);
|
||||||
|
my $epact = ($quasicentury - int($quasicentury/4) -
|
||||||
|
int(($quasicentury * 8 + 13)/25) + ($golden_number*19) + 15) % 30;
|
||||||
|
|
||||||
|
my $interval = $epact - int($epact/28)*
|
||||||
|
(1 - int(29/($epact+1)) * int((21 - $golden_number)/11) );
|
||||||
|
my $weekday = ($year + int($year/4) + $interval +
|
||||||
|
2 - $quasicentury + int($quasicentury/4)) % 7;
|
||||||
|
|
||||||
|
my $offset = $interval - $weekday;
|
||||||
|
my $month = 3 + int(($offset+40)/44);
|
||||||
|
my $day = $offset + 28 - 31* int($month/4);
|
||||||
|
|
||||||
|
return $month, $day;
|
||||||
|
}
|
||||||
1;
|
1;
|
||||||
|
@ -6631,10 +6631,6 @@ href="http://www.elv.de/output/controller.aspx?cid=74&detail=10&detail2=29870">U
|
|||||||
<a name="holiday"></a>
|
<a name="holiday"></a>
|
||||||
<h3>holiday</h3>
|
<h3>holiday</h3>
|
||||||
<ul>
|
<ul>
|
||||||
Note: this module requires the "DateTime::Event::Easter" perl module for all
|
|
||||||
easter related holidays.
|
|
||||||
<br><br>
|
|
||||||
|
|
||||||
<a name="holidaydefine"></a>
|
<a name="holidaydefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user