/** * AgaviTimeZone API. * * @see AgaviTimeZone::useDaylightTime() * * @author Dominik del Bondio <*****@*****.**> * @author The ICU Project * @since 0.11.0 */ public function useDaylightTime() { // If DST was observed in 1942 (for example) but has never been // observed from 1943 to the present, most clients will expect // this method to return FALSE. This method determines whether // DST is in use in the current year (at any point in the year) // and returns TRUE if so. $days = floor(AgaviCalendar::getNow() / AgaviDateDefinitions::MILLIS_PER_DAY); // epoch days $year = 0; $month = 0; $dom = 0; $dow = 0; AgaviCalendarGrego::dayToFields($days, $year, $month, $dom, $dow); if ($year > $this->finalYear) { // [sic] >, not >=; see above if ($this->finalZone) { return $this->finalZone->useDaylightTime(); } else { return true; } } // Find start of this year, and start of next year $start = (int) AgaviCalendarGrego::fieldsToDay($year, 0, 1) * AgaviDateDefinitions::SECONDS_PER_DAY; $limit = (int) AgaviCalendarGrego::fieldsToDay($year + 1, 0, 1) * AgaviDateDefinitions::SECONDS_PER_DAY; // Return TRUE if DST is observed at any time during the current year. for ($i = 0, $transitionCount = count($this->transitions); $i < $transitionCount; ++$i) { if ($this->transitions[$i]['time'] >= $limit) { break; } if ($this->transitions[$i]['time'] >= $start && $this->types[$this->transitions[$i]['type']]['dstOffset'] != 0 || $this->transitions[$i]['time'] > $start && $i > 0 && $this->types[$this->transitions[$i - 1]['type']]['dstOffset'] != 0) { return true; } } return false; }