예제 #1
0
 public function test_constant_UTC()
 {
     $test = ZoneOffset::UTC();
     $this->assertEquals($test->getId(), "Z");
     $this->assertEquals($test->getDisplayName(TextStyle::FULL(), Locale::UK()), "Z");
     $this->assertEquals($test->getRules()->isFixedOffset(), true);
     $this->assertEquals($test->getRules()->getOffset(Instant::ofEpochSecond(0)), ZoneOffset::UTC());
     $this->checkOffset($test->getRules(), $this->createLDT(2008, 6, 30), ZoneOffset::UTC(), 1);
 }
예제 #2
0
 function providerDayOfWeekData()
 {
     return [[Locale::US(), "e", "1", DayOfWeek::SUNDAY()], [Locale::US(), "ee", "01", DayOfWeek::SUNDAY()], [Locale::US(), "c", "1", DayOfWeek::SUNDAY()], [Locale::UK(), "e", "1", DayOfWeek::MONDAY()], [Locale::UK(), "ee", "01", DayOfWeek::MONDAY()], [Locale::UK(), "c", "1", DayOfWeek::MONDAY()]];
 }
예제 #3
0
 /**
  * @dataProvider data_offsetBasedValidPrefix
  */
 public function test_factory_of_String_offsetBasedValid_prefixUT($input, $id, $offsetId)
 {
     $test = ZoneId::of("UT" . $input);
     $this->assertEquals($test->getId(), "UT" . $id);
     $this->assertEquals($test->getRules(), ZoneOffset::of($offsetId)->getRules());
     $this->assertEquals($test->normalized(), ZoneOffset::of($offsetId));
     $this->assertEquals($test->getRules()->isFixedOffset(), true);
     $this->assertEquals($test->getRules()->getOffset(Instant::EPOCH()), ZoneOffset::of($offsetId));
     if (defined('HHVM_VERSION')) {
         $this->markTestSkipped('See https://github.com/facebook/hhvm/issues/6852');
     }
     $this->assertEquals($test->getDisplayName(TextStyle::FULL(), Locale::UK()), $this->displayName("UT" . $id));
 }
 public function test_adjacent_lenient_fractionFollows_0digit()
 {
     // succeeds because hour/min are fixed width
     $f = $this->builder->parseLenient()->appendValue2(ChronoField::HOUR_OF_DAY(), 2)->appendValue2(ChronoField::MINUTE_OF_HOUR(), 2)->appendFraction(ChronoField::NANO_OF_SECOND(), 3, 3, false)->toFormatter2(Locale::UK());
     $pp = new ParsePosition(0);
     $parsed = $f->parseUnresolved("1230", $pp);
     $this->assertEquals($pp->getErrorIndex(), -1);
     $this->assertEquals($pp->getIndex(), 4);
     $this->assertEquals($parsed->getLong(ChronoField::HOUR_OF_DAY()), 12);
     $this->assertEquals($parsed->getLong(ChronoField::MINUTE_OF_HOUR()), 30);
 }
 public function test_pattern_StringLocale_nullPattern()
 {
     TestHelper::assertNullException($this, function () {
         DateTimeFormatter::ofPatternLocale(null, Locale::UK());
     });
 }
 /**
  * @dataProvider data_patternPrint
  */
 public function test_appendPattern_patternPrint($input, Temporal $temporal, $expected)
 {
     $f = $this->builder->appendPattern($input)->toFormatter2(Locale::UK());
     $test = $f->format($temporal);
     $this->assertEquals($test, $expected);
 }
 function data_time()
 {
     return [[LocalTime::of(11, 30), FormatStyle::SHORT(), \IntlDateFormatter::SHORT, Locale::UK()], [LocalTime::of(11, 30), FormatStyle::SHORT(), \IntlDateFormatter::SHORT, Locale::US()], [LocalTime::of(11, 30), FormatStyle::SHORT(), \IntlDateFormatter::SHORT, Locale::FRANCE()], [LocalTime::of(11, 30), FormatStyle::SHORT(), \IntlDateFormatter::SHORT, Locale::JAPAN()], [LocalTime::of(11, 30), FormatStyle::MEDIUM(), \IntlDateFormatter::MEDIUM, Locale::UK()], [LocalTime::of(11, 30), FormatStyle::MEDIUM(), \IntlDateFormatter::MEDIUM, Locale::US()], [LocalTime::of(11, 30), FormatStyle::MEDIUM(), \IntlDateFormatter::MEDIUM, Locale::FRANCE()], [LocalTime::of(11, 30), FormatStyle::MEDIUM(), \IntlDateFormatter::MEDIUM, Locale::JAPAN()]];
 }