The problem is, that for example 2:00am or 2:59am are doubled in autumn in some timezones and don't exist in spring during the DST time-saving change.
If I run a PHP loop through every minute through a whole year, how can I catch the DST timesavings hour within the loop? (in the current Timezone, set by date_default_timezone_set)
How would I complete a PHP 5.2 compatible function like:
<?php
/** returns true if a time is skipped or doubled
* (for example "2013-03-10 02:30" doesen't exist in USA)
*
* @param string $season
* @param string $datestring in the form of "2013-03-10 02:30"
* @return boolean
**/
function checkDST($datestring,$season="any"){
$tz=date_default_timezone_get();
$season=strtolower(trim($season));
if($season=="spring"){
if(/* an hour skipped */) return true;
}else if($season=="autumn"){
if(/* double hour */) return true;
} else if($season=="any") {
if(/* any of both */) return true;
}
return false
}
so I could use
date_default_timezone_set("America/New_York");
$is_skipped=checkDST("2013-03-10 02:30","spring");
and
$exists_two_times=checkDST(2003-11-03, 02:00,"autumn"); // or 2:59 for example
(Timezones see: http://www.timeanddate.com/worldclock/clockchange.html?n=224&year=2013 )
EDIT:
I found out how to detect the spring DST:
function checkDST($datestring,$season="any"){
var_dump('checking '.$datestring);
$season=strtolower(trim($season));
$datestring=substr($datestring,0,16);
if($season!="autumn" and date("Y-m-d H:i",strtotime($datestring))!=$datestring) {
return true;
}
// check for double hours in autumn
...