Temat: easter_date
Witam dlaczego ta funkcja nie działa "easter_date"
$easter = date ( 'm-d' , easter_date ( $year ));
wywala błąd "Call to undefined function easter_date() in"
zainstalowane mam zoneinfo-core zoneinfo-europe
Nie jesteś zalogowany. Proszę się zalogować lub zarejestrować.
eko.one.pl → Inne → easter_date
Strony 1
Zaloguj się lub zarejestruj by napisać odpowiedź
Witam dlaczego ta funkcja nie działa "easter_date"
$easter = date ( 'm-d' , easter_date ( $year ));
wywala błąd "Call to undefined function easter_date() in"
zainstalowane mam zoneinfo-core zoneinfo-europe
php?
tak
W openwrt? Wg manuala bazuje to na bibliotece systemowej (libc), w openwrt masz uproszczony uclibc...
Wypróbuj może tego.
Mnie liczy dobrze.
function easter_dates ( $Year ) {
/*
G is the Golden Number-1
H is 23-Epact (modulo 30)
I is the number of days from 21 March to the Paschal full moon
J is the weekday for the Paschal full moon (0=Sunday,
1=Monday, etc.)
L is the number of days from 21 March to the Sunday on or before
the Paschal full moon (a number between -6 and 28)
*/
$G = $Year % 19 ;
$C = (int)( $Year / 100 );
$H = (int)( $C - (int)( $C / 4 ) - (int)(( 8 * $C + 13 ) / 25 ) + 19 * $G + 15 ) % 30 ;
$I = (int) $H - (int)( $H / 28 )*( 1 - (int)( $H / 28 )*(int)( 29 / ( $H + 1 ))*((int)( 21 - $G ) / 11 ));
$J = ( $Year + (int)( $Year / 4 ) + $I + 2 - $C + (int)( $C / 4 )) % 7 ;
$L = $I - $J ;
$m = 3 + (int)(( $L + 40 ) / 44 );
$d = $L + 28 - 31 * ((int)( $m / 4 ));
$y = $Year ;
$E = mktime ( 0 , 0 , 0 , $m , $d , $y );
return $E ;
}
mam takie coś:
function easter_date ( $year ) {
$G = $Year % 19 ;//G is the Golden Number-1
$C = (int)( $Year / 100 );
$H = (int)( $C - (int)( $C / 4 ) - (int)(( 8 * $C + 13 ) / 25 ) + 19 * $G + 15 ) % 30 ;//H is 23-Epact (modulo 30)
$I = (int) $H - (int)( $H / 28 )*( 1 - (int)( $H / 28 )*(int)( 29 / ( $H + 1 ))*((int)( 21 - $G ) / 11 ));//I is the number of days from 21 March to the Paschal full moon
$J = ( $Year + (int)( $Year / 4 ) + $I + 2 - $C + (int)( $C / 4 )) % 7 ;//J is the weekday for the Paschal full moon (0=Sunday,1=Monday, etc.)
$L = $I - $J ;//L is the number of days from 21 March to the Sunday on or before the Paschal full moon (a number between -6 and 28)
$m = 3 + (int)(( $L + 40 ) / 44 );
$d = $L + 28 - 31 * ((int)( $m / 4 ));
$y = $Year ;
$E = mktime ( 0 , 0 , 0 , $m , $d , $y );
return $E ;
}
function WorkingDay($date) {
$time = strtotime($date);
$dayOfWeek = (int)date('w',$time);
$year = (int)date('Y',$time);
if( $dayOfWeek==6 || $dayOfWeek==0 ) {//sprawdzenie czy to nie weekend
return false;
}
$holiday=array('01-01', '01-06','05-01','05-03','08-15','11-01','11-11','12-25','12-26');//lista swiat stalych
$easter = date ( 'm-d' , easter_date ( $year ));//dodanie listy swiat ruchomych wialkanoc
$easterSec = date('m-d', strtotime('+1 day', strtotime( $year . '-' . $easter) ));//poniedzialek wielkanocny
$cc = date('m-d', strtotime('+60 days', strtotime( $year . '-' . $easter) ));//boze cialo
$p = date('m-d', strtotime('+49 days', strtotime( $year . '-' . $easter) ));//Zesłanie Ducha Świętego
$holiday[] = $easter;
$holiday[] = $easterSec;
$holiday[] = $cc;
$holiday[] = $p;
$md = date('m-d',strtotime($date));
if(in_array($md, $holiday)) return false;
return true;
} //echo WorkingDay(date("Y-m-d"));
//echo WorkingDay("2016-3-28");
echo date ( 'm-d' , easter_date ( 2017 )); //tu zle liczy
co jest nie tak
Wyliczyłem moją funkcją i wyszło 04-16
Dla Twojej wyszło 04-09.
no właśnie w tym jest błąd wywołanie twojej funkcji daje mi błąd
napisz jak ty liczysz bo w twojej funkcji nic nie zmieniałem (logicznego)
Może to, że moja nazwa funkcji to easter_dates ?
Napisz jak ją wywołujesz u siebie ?
echo date ( 'm-d' , easter_dates ( 2017 ));
ok dzięki za pomoc i za kod
powinni być function easter_date ( $Year ) {
a było u mnie function easter_date ( $year ) {
i tu błąd
Strony 1
Zaloguj się lub zarejestruj by napisać odpowiedź
eko.one.pl → Inne → easter_date
Forum oparte o PunBB, wspierane przez Informer Technologies, Inc