Esempio n. 1
0
 /**
  * AgaviTimeZone API.
  *
  * @see        AgaviTimeZone::getOffsetRef()
  * 
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     The ICU Project
  * @since      0.11.0
  */
 public function getOffsetRef($date, $local, &$rawoff, &$dstoff)
 {
     // The check against finalMillis will suffice most of the time, except
     // for the case in which finalMillis == DBL_MAX, date == DBL_MAX,
     // and finalZone == 0.  For this case we add "&& finalZone != 0".
     if ($date >= $this->finalMillis && $this->finalZone !== null) {
         $millis = 0;
         $days = AgaviToolkit::floorDivide($date, AgaviDateDefinitions::MILLIS_PER_DAY, $millis);
         $year = 0;
         $month = 0;
         $dom = 0;
         $dow = 0;
         AgaviCalendarGrego::dayToFields($days, $year, $month, $dom, $dow);
         $rawoff = $this->finalZone->getRawOffset();
         if (!$local) {
             // Adjust from GMT to local
             $date += $rawoff;
             $days2 = AgaviToolkit::floorDivide($date, AgaviDateDefinitions::MILLIS_PER_DAY, $millis);
             if ($days2 != $days) {
                 AgaviCalendarGrego::dayToFields($days2, $year, $month, $dom, $dow);
             }
         }
         $dstoff = $this->finalZone->getOffset(AgaviGregorianCalendar::AD, $year, $month, $dom, $dow, $millis) - $rawoff;
         return;
     }
     $secs = floor($date / AgaviDateDefinitions::MILLIS_PER_SECOND);
     $transition = $this->findTransition($secs, $local);
     $rawoff = $this->types[$transition['type']]['rawOffset'] * AgaviDateDefinitions::MILLIS_PER_SECOND;
     $dstoff = $this->types[$transition['type']]['dstOffset'] * AgaviDateDefinitions::MILLIS_PER_SECOND;
 }
 /**
  * @see        AgaviCalendar::handleGetMonthLength
  * 
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     The ICU Project
  * @since      0.11.0
  */
 protected function handleGetMonthLength($extendedYear, $month)
 {
     // If the month is out of range, adjust it into range, and
     // modify the extended year value accordingly.
     if ($month < 0 || $month > 11) {
         $extendedYear += AgaviToolkit::floorDivide($month, 12, $month);
     }
     return $this->isLeapYear($extendedYear) ? self::$kLeapMonthLength[$month] : self::$kMonthLength[$month];
 }
 /**
  * Return the day of week on the 1970-epoch day
  * 
  * @param      float  day the 1970-epoch day (integral value)
  * 
  * @return     int    the day of week
  * 
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     The ICU Project
  * @since      1.0.1
  */
 public static function dayOfWeek($day)
 {
     $dow = null;
     AgaviToolkit::floorDivide($day + AgaviDateDefinitions::THURSDAY, 7, $dow);
     return $dow == 0 ? AgaviDateDefinitions::SATURDAY : $dow;
 }
Esempio n. 4
0
 /**
  * @expectedException PHPUnit_Framework_Error
  */
 public function testFloorDivideByZero()
 {
     AgaviToolkit::floorDivide(10, 0, $rem);
 }