CC-3956: PHP script can enter inifinite loop

-small cleanup
This commit is contained in:
Martin Konecny 2012-06-12 20:18:06 -04:00
parent d1c224321b
commit 02b6d04952
1 changed files with 10 additions and 12 deletions

View File

@ -1359,30 +1359,28 @@ class Application_Model_Show {
* over the years 2011->2012, etc.). Then let's append the actual day, and use the php
* checkdate() function, to see if it is valid. If not, then we'll just skip this month. */
/* pass in only the year and month (not the day) */
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* pass in only the year and month (not the day) */
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* Keep adding 1 month, until we find the next month that contains the day
* we are looking for (31st day for example) */
do {
$dt->add(new DateInterval($p_interval));
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
} else {
$dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
}
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
return array($start, $utcStartDateTime);
}