Ejemplo n.º 1
0
 /**
  * Converts Calendar's time field values to GMT as milliseconds.
  *
  * @author     Dominik del Bondio <*****@*****.**>
  * @author     The ICU Project
  * @since      0.11.0
  */
 protected function computeTime()
 {
     if (!$this->isLenient()) {
         $this->validateFields();
     }
     // Compute the Julian day
     $julianDay = $this->computeJulianDay();
     $millis = AgaviCalendarGrego::julianDayToMillis($julianDay);
     $millisInDay = 0;
     // We only use MILLISECONDS_IN_DAY if it has been set by the user.
     // This makes it possible for the caller to set the calendar to a
     // time and call clear(MONTH) to reset the MONTH to January.  This
     // is legacy behavior.  Without this, clear(MONTH) has no effect,
     // since the internally set JULIAN_DAY is used.
     if ($this->fStamp[AgaviDateDefinitions::MILLISECONDS_IN_DAY] >= self::kMinimumUserStamp && $this->newestStamp(AgaviDateDefinitions::AM_PM, AgaviDateDefinitions::MILLISECOND, self::kUnset) <= $this->fStamp[AgaviDateDefinitions::MILLISECONDS_IN_DAY]) {
         $millisInDay = $this->internalGet(AgaviDateDefinitions::MILLISECONDS_IN_DAY);
     } else {
         $millisInDay = $this->computeMillisInDay();
     }
     // Compute the time zone offset and DST offset.  There are two potential
     // ambiguities here.  We'll assume a 2:00 am (wall time) switchover time
     // for discussion purposes here.
     // 1. The transition into DST.  Here, a designated time of 2:00 am - 2:59 am
     //    can be in standard or in DST depending.  However, 2:00 am is an invalid
     //    representation (the representation jumps from 1:59:59 am Std to 3:00:00 am DST).
     //    We assume standard time.
     // 2. The transition out of DST.  Here, a designated time of 1:00 am - 1:59 am
     //    can be in standard or DST.  Both are valid representations (the rep
     //    jumps from 1:59:59 DST to 1:00:00 Std).
     //    Again, we assume standard time.
     // We use the TimeZone object, unless the user has explicitly set the ZONE_OFFSET
     // or DST_OFFSET fields; then we use those fields.
     if ($this->fStamp[AgaviDateDefinitions::ZONE_OFFSET] >= self::kMinimumUserStamp || $this->fStamp[AgaviDateDefinitions::DST_OFFSET] >= self::kMinimumUserStamp) {
         $millisInDay -= $this->internalGet(AgaviDateDefinitions::ZONE_OFFSET) + $this->internalGet(AgaviDateDefinitions::DST_OFFSET);
     } else {
         $millisInDay -= $this->computeZoneOffset($millis, $millisInDay);
     }
     $this->internalSetTime($millis + $millisInDay);
 }