Horde_Mapi_Timezone::_checkTransition PHP Method

_checkTransition() protected method

Check if the given standardTransition and daylightTransition match to the given offsets.
protected _checkTransition ( array $std, array $dst, array $offsets ) : boolean
$std array The Standard transition date.
$dst array The DST transition date.
$offsets array The offsets to check.
return boolean
    protected function _checkTransition(array $std, array $dst, array $offsets)
    {
        if (empty($std) || empty($offsets)) {
            return false;
        }
        $standardOffset = ($offsets['bias'] + $offsets['stdbias']) * 60 * -1;
        // check each condition in a single if statement and break the chain
        // when one condition is not met - for performance reasons
        if ($standardOffset == $std['offset']) {
            if (empty($offsets['dstmonth']) && (empty($dst) || empty($dst['isdst'])) || empty($dst) && !empty($offsets['dstmonth'])) {
                // Offset contains DST, but no dst to compare
                return true;
            }
            $daylightOffset = ($offsets['bias'] + $offsets['dstbias']) * 60 * -1;
            // the milestone is sending a positive value for daylightBias while it should send a negative value
            $daylightOffsetMilestone = ($offsets['dstbias'] + $offsets['dstbias'] * -1) * 60 * -1;
            if ($daylightOffset == $dst['offset'] || $daylightOffsetMilestone == $dst['offset']) {
                $standardParsed = new DateTime($std['time']);
                $daylightParsed = new DateTime($dst['time']);
                if ($standardParsed->format('n') == $offsets['stdmonth'] && $daylightParsed->format('n') == $offsets['dstmonth'] && $standardParsed->format('w') == $offsets['stdday'] && $daylightParsed->format('w') == $offsets['dstday']) {
                    return self::_isNthOcurrenceOfWeekdayInMonth($dst['ts'], $offsets['dstweek']) && self::_isNthOcurrenceOfWeekdayInMonth($std['ts'], $offsets['stdweek']);
                }
            }
        }
        return false;
    }