Exemplo n.º 1
0
 private function doTestOffset(ZoneOffset $offset, $hours, $minutes, $seconds)
 {
     $this->assertEquals($offset->getTotalSeconds(), $hours * 60 * 60 + $minutes * 60 + $seconds);
     if ($hours == 0 && $minutes == 0 && $seconds == 0) {
         $id = "Z";
     } else {
         $str = $hours < 0 || $minutes < 0 || $seconds < 0 ? "-" : "+";
         $str .= substr(Math::abs($hours) + 100, 1);
         $str .= ":";
         $str .= substr(Math::abs($minutes) + 100, 1);
         if ($seconds != 0) {
             $str .= ":";
             $str .= substr(Math::abs($seconds) + 100, 1);
         }
         $id = $str;
     }
     $this->assertEquals($offset->getId(), $id);
     $this->assertEquals($offset, ZoneOffset::ofHoursMinutesSeconds($hours, $minutes, $seconds));
     if ($seconds == 0) {
         $this->assertEquals($offset, ZoneOffset::ofHoursMinutes($hours, $minutes));
         if ($minutes == 0) {
             $this->assertEquals($offset, ZoneOffset::ofHours($hours));
         }
     }
     $this->assertEquals(ZoneOffset::of($id), $offset);
     $this->assertEquals($offset->__toString(), $id);
 }
 public function provider_offsets()
 {
     return [["+HH", "+00", ZoneOffset::UTC()], ["+HH", "-00", ZoneOffset::UTC()], ["+HH", "+01", ZoneOffset::ofHours(1)], ["+HH", "-01", ZoneOffset::ofHours(-1)], ["+HHMM", "+0000", ZoneOffset::UTC()], ["+HHMM", "-0000", ZoneOffset::UTC()], ["+HHMM", "+0102", ZoneOffset::ofHoursMinutes(1, 2)], ["+HHMM", "-0102", ZoneOffset::ofHoursMinutes(-1, -2)], ["+HH:MM", "+00:00", ZoneOffset::UTC()], ["+HH:MM", "-00:00", ZoneOffset::UTC()], ["+HH:MM", "+01:02", ZoneOffset::ofHoursMinutes(1, 2)], ["+HH:MM", "-01:02", ZoneOffset::ofHoursMinutes(-1, -2)], ["+HHMMss", "+0000", ZoneOffset::UTC()], ["+HHMMss", "-0000", ZoneOffset::UTC()], ["+HHMMss", "+0100", ZoneOffset::ofHoursMinutesSeconds(1, 0, 0)], ["+HHMMss", "+0159", ZoneOffset::ofHoursMinutesSeconds(1, 59, 0)], ["+HHMMss", "+0200", ZoneOffset::ofHoursMinutesSeconds(2, 0, 0)], ["+HHMMss", "+1800", ZoneOffset::ofHoursMinutesSeconds(18, 0, 0)], ["+HHMMss", "+010215", ZoneOffset::ofHoursMinutesSeconds(1, 2, 15)], ["+HHMMss", "-0100", ZoneOffset::ofHoursMinutesSeconds(-1, 0, 0)], ["+HHMMss", "-0200", ZoneOffset::ofHoursMinutesSeconds(-2, 0, 0)], ["+HHMMss", "-1800", ZoneOffset::ofHoursMinutesSeconds(-18, 0, 0)], ["+HHMMss", "+000000", ZoneOffset::UTC()], ["+HHMMss", "-000000", ZoneOffset::UTC()], ["+HHMMss", "+010000", ZoneOffset::ofHoursMinutesSeconds(1, 0, 0)], ["+HHMMss", "+010203", ZoneOffset::ofHoursMinutesSeconds(1, 2, 3)], ["+HHMMss", "+015959", ZoneOffset::ofHoursMinutesSeconds(1, 59, 59)], ["+HHMMss", "+020000", ZoneOffset::ofHoursMinutesSeconds(2, 0, 0)], ["+HHMMss", "+180000", ZoneOffset::ofHoursMinutesSeconds(18, 0, 0)], ["+HHMMss", "-010000", ZoneOffset::ofHoursMinutesSeconds(-1, 0, 0)], ["+HHMMss", "-020000", ZoneOffset::ofHoursMinutesSeconds(-2, 0, 0)], ["+HHMMss", "-180000", ZoneOffset::ofHoursMinutesSeconds(-18, 0, 0)], ["+HH:MM:ss", "+00:00", ZoneOffset::UTC()], ["+HH:MM:ss", "-00:00", ZoneOffset::UTC()], ["+HH:MM:ss", "+01:00", ZoneOffset::ofHoursMinutesSeconds(1, 0, 0)], ["+HH:MM:ss", "+01:02", ZoneOffset::ofHoursMinutesSeconds(1, 2, 0)], ["+HH:MM:ss", "+01:59", ZoneOffset::ofHoursMinutesSeconds(1, 59, 0)], ["+HH:MM:ss", "+02:00", ZoneOffset::ofHoursMinutesSeconds(2, 0, 0)], ["+HH:MM:ss", "+18:00", ZoneOffset::ofHoursMinutesSeconds(18, 0, 0)], ["+HH:MM:ss", "+01:02:15", ZoneOffset::ofHoursMinutesSeconds(1, 2, 15)], ["+HH:MM:ss", "-01:00", ZoneOffset::ofHoursMinutesSeconds(-1, 0, 0)], ["+HH:MM:ss", "-02:00", ZoneOffset::ofHoursMinutesSeconds(-2, 0, 0)], ["+HH:MM:ss", "-18:00", ZoneOffset::ofHoursMinutesSeconds(-18, 0, 0)], ["+HH:MM:ss", "+00:00:00", ZoneOffset::UTC()], ["+HH:MM:ss", "-00:00:00", ZoneOffset::UTC()], ["+HH:MM:ss", "+01:00:00", ZoneOffset::ofHoursMinutesSeconds(1, 0, 0)], ["+HH:MM:ss", "+01:02:03", ZoneOffset::ofHoursMinutesSeconds(1, 2, 3)], ["+HH:MM:ss", "+01:59:59", ZoneOffset::ofHoursMinutesSeconds(1, 59, 59)], ["+HH:MM:ss", "+02:00:00", ZoneOffset::ofHoursMinutesSeconds(2, 0, 0)], ["+HH:MM:ss", "+18:00:00", ZoneOffset::ofHoursMinutesSeconds(18, 0, 0)], ["+HH:MM:ss", "-01:00:00", ZoneOffset::ofHoursMinutesSeconds(-1, 0, 0)], ["+HH:MM:ss", "-02:00:00", ZoneOffset::ofHoursMinutesSeconds(-2, 0, 0)], ["+HH:MM:ss", "-18:00:00", ZoneOffset::ofHoursMinutesSeconds(-18, 0, 0)], ["+HHMMSS", "+000000", ZoneOffset::UTC()], ["+HHMMSS", "-000000", ZoneOffset::UTC()], ["+HHMMSS", "+010203", ZoneOffset::ofHoursMinutesSeconds(1, 2, 3)], ["+HHMMSS", "-010203", ZoneOffset::ofHoursMinutesSeconds(-1, -2, -3)], ["+HH:MM:SS", "+00:00:00", ZoneOffset::UTC()], ["+HH:MM:SS", "-00:00:00", ZoneOffset::UTC()], ["+HH:MM:SS", "+01:02:03", ZoneOffset::ofHoursMinutesSeconds(1, 2, 3)], ["+HH:MM:SS", "-01:02:03", ZoneOffset::ofHoursMinutesSeconds(-1, -2, -3)]];
 }
 private static function OFFSET_M0023()
 {
     return ZoneOffset::ofHoursMinutes(0, -23);
 }
Exemplo n.º 4
0
 private static function OFFSET_0230()
 {
     return ZoneOffset::ofHoursMinutes(2, 30);
 }
 function data_parseSuccess()
 {
     return [["Z", 1, -1, ZoneId::of("Z")], ["UTC", 3, -1, ZoneId::of("UTC")], ["UT", 2, -1, ZoneId::of("UT")], ["GMT", 3, -1, ZoneId::of("GMT")], ["+00:00", 6, -1, ZoneOffset::UTC()], ["UTC+00:00", 9, -1, ZoneId::of("UTC")], ["UT+00:00", 8, -1, ZoneId::of("UT")], ["GMT+00:00", 9, -1, ZoneId::of("GMT")], ["-00:00", 6, -1, ZoneOffset::UTC()], ["UTC-00:00", 9, -1, ZoneId::of("UTC")], ["UT-00:00", 8, -1, ZoneId::of("UT")], ["GMT-00:00", 9, -1, ZoneId::of("GMT")], ["+01:30", 6, -1, ZoneOffset::ofHoursMinutes(1, 30)], ["UTC+01:30", 9, -1, ZoneId::of("UTC+01:30")], ["UT+02:30", 8, -1, ZoneId::of("UT+02:30")], ["GMT+03:30", 9, -1, ZoneId::of("GMT+03:30")], ["-01:30", 6, -1, ZoneOffset::ofHoursMinutes(-1, -30)], ["UTC-01:30", 9, -1, ZoneId::of("UTC-01:30")], ["UT-02:30", 8, -1, ZoneId::of("UT-02:30")], ["GMT-03:30", 9, -1, ZoneId::of("GMT-03:30")], ["UTC-01:WW", 3, -1, ZoneId::of("UTC")], ["UT-02:WW", 2, -1, ZoneId::of("UT")], ["GMT-03:WW", 3, -1, ZoneId::of("GMT")], ["Z0", 1, -1, ZoneOffset::UTC()], ["UTC1", 3, -1, ZoneId::of("UTC")], ["UTCZ", 3, -1, ZoneId::of("UTC")], ["UTZ", 2, -1, ZoneId::of("UT")], ["GMTZ", 3, -1, ZoneId::of("GMT")], ["UTC0", 3, -1, ZoneId::of("UTC")], ["UT0", 2, -1, ZoneId::of("UT")], ["", 0, 0, null], ["A", 0, 0, null], ["UZ", 0, 0, null], ["GMA", 0, 0, null], ["0", 0, 0, null], ["+", 0, 0, null], ["-", 0, 0, null], ["Europe/London", 13, -1, ZoneId::of("Europe/London")], ["America/New_York", 16, -1, ZoneId::of("America/New_York")], ["America/Bogusville", 0, 0, null]];
 }