Ejemplo n.º 1
0
 public function testMake()
 {
     $time = new CTime(0);
     $this->assertTrue($time->toStringUtc(CTime::PATTERN_MYSQL)->equals("1970-01-01 00:00:00"));
     $time = new CTime(1234567890);
     $this->assertTrue($time->toStringUtc(CTime::PATTERN_MYSQL)->equals("2009-02-13 23:31:30"));
     $time = new CTime(-1234567890);
     $this->assertTrue($time->toStringUtc(CTime::PATTERN_MYSQL)->equals("1930-11-18 00:28:30"));
     $time = new CTime(1234567890, 250);
     $this->assertTrue($time->toStringUtc(CTime::PATTERN_MYSQL)->equals("2009-02-13 23:31:30") && $time->FTime() === 1234567890.25 && $time->UTime() === 1234567890 && $time->MTime() === 250);
     $time = new CTime(-1234567890, -250);
     $this->assertTrue($time->toStringUtc(CTime::PATTERN_MYSQL)->equals("1930-11-18 00:28:30") && $time->FTime() === -1234567890.25 && $time->UTime() === -1234567890 && $time->MTime() === -250);
 }
Ejemplo n.º 2
0
 protected static function timeToComponentsInTimeZone(CTime $time, $timeZone, &$year, &$month, &$day, &$hour, &$minute, &$second, &$millisecond, &$dayOfWeek)
 {
     $FTime = $time->FTime();
     $UTime = $time->UTime();
     $MTime = $time->MTime();
     $negMsCase = false;
     if ($FTime < 0.0 && $MTime != 0) {
         $negMsCase = true;
         $UTime--;
     }
     $time = self::timeToStringInTimeZone(new self($UTime), "Y,m,d,H,i,s,w", $timeZone);
     $components = CString::split($time, ",");
     $year = CString::toInt($components[0]);
     $month = CString::toInt($components[1]);
     $day = CString::toInt($components[2]);
     $hour = CString::toInt($components[3]);
     $minute = CString::toInt($components[4]);
     $second = CString::toInt($components[5]);
     $dayOfWeek = CString::toInt($components[6]);
     if (!$negMsCase) {
         $millisecond = $MTime;
     } else {
         $millisecond = $MTime + 1000;
     }
 }