public function testFormatValueDateParts()
 {
     $messageFormatter = MessageFormatter::createDateValueFormatter('de_DE');
     $date = new DateTime('2016-04-01');
     $this->assertSame('2016', $messageFormatter->formatValue('date_year', $date));
     $this->assertSame('4', $messageFormatter->formatValue('date_month', $date));
     $this->assertSame('April', $messageFormatter->formatValue('date_month_name', $date));
     $this->assertSame('1', $messageFormatter->formatValue('date_day', $date));
     $this->assertSame('Freitag', $messageFormatter->formatValue('date_weekday', $date));
 }
Exemplo n.º 2
0
 /**
  * @param string $locale
  * @return IntlFormat
  */
 public function createIntlFormat(string $locale) : IntlFormat
 {
     $formatter = [MessageFormatter::createDateValueFormatter($locale), MessageFormatter::createNumberValueFormatter($locale), new TimeZoneFormatter($locale), new LocaleFormatter($locale)];
     return new IntlFormat($formatter);
 }