note 111807 added to function.easter-date

From: Date: Sat, 30 Mar 2013 08:13:58 +0000
Subject: note 111807 added to function.easter-date
Groups: php.notes 
Request: Send a blank email to php-notes+get-194274@lists.php.net to get a copy of this message
I found a problem with holidays timestamp computation and daylight saving time. An article about it at http://goo.gl/76t31 (in french only, sorry). In summary, this year (2013) easter begins before adding an hour for daylight saving time (occured sunday at 3:00). It means that if you do $easter + X, where x is a number of seconds equivalent to one day, 39 days or 50 days, the result is not equals to a midnight timestamp... Here a function to check if a midnight timestamp is equals to an holiday : function isHoliday( $ts ) { // Licence : Creative Commons (BY) // By Webpulser - http://goo.gl/76t31 $fixed_holidays = array( ’01-01′, ’01-05′, ’08-05′, ’14-07′, ’15-08′, ’11-11′, ’25-12′ ); $format = ‘d-m’; $dm = date($format, $ts); if ( in_array($dm, $fixed_holidays) ) return true; $easter = easter_date( date(‘Y’, $ts) ); if ( date($format, $easter + 86400) == $dm ) return true; if ( date($format, $easter + 3369600) == $dm ) return true; if ( date($format, $easter + 4320000) == $dm ) return true; return false; } feel free to use / modify. ---- Server IP: 69.147.83.199 Probable Submitter: 81.67.45.18 ---- Manual Page -- http://php.net/manual/en/function.easter-date.php Edit -- https://master.php.net/note/edit/111807 Del: integrated -- https://master.php.net/note/delete/111807/integrated Del: useless -- https://master.php.net/note/delete/111807/useless Del: bad code -- https://master.php.net/note/delete/111807/bad+code Del: spam -- https://master.php.net/note/delete/111807/spam Del: non-english -- https://master.php.net/note/delete/111807/non-english Del: in docs -- https://master.php.net/note/delete/111807/in+docs Del: other reasons-- https://master.php.net/note/delete/111807 Reject -- https://master.php.net/note/reject/111807 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194274) next »