コード例 #1
0
 public function data_formatStyle()
 {
     return [[ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::ZONEID_PARIS()), FormatStyle::FULL(), "Tuesday, October 2, 2001 1:02:03 AM CEST Europe/Paris"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::ZONEID_PARIS()), FormatStyle::LONG(), "October 2, 2001 1:02:03 AM CEST Europe/Paris"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::ZONEID_PARIS()), FormatStyle::MEDIUM(), "Oct 2, 2001, 1:02:03 AM Europe/Paris"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::ZONEID_PARIS()), FormatStyle::SHORT(), "10/2/01, 1:02 AM Europe/Paris"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::OFFSET_PTWO()), FormatStyle::FULL(), "Tuesday, October 2, 2001 at 1:02:03 AM +02:00 +02:00"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::OFFSET_PTWO()), FormatStyle::LONG(), "October 2, 2001 at 1:02:03 AM +02:00 +02:00"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::OFFSET_PTWO()), FormatStyle::MEDIUM(), "Oct 2, 2001, 1:02:03 AM +02:00"], [ZonedDateTime::ofDateTime(LocalDateTime::of(2001, 10, 2, 1, 2, 3), self::OFFSET_PTWO()), FormatStyle::SHORT(), "10/2/01, 1:02 AM +02:00"]];
 }
コード例 #2
0
ファイル: FormatStyle.php プロジェクト: celest-time/prototype
        }
        throw new IllegalArgumentException();
    }
    function ordinal()
    {
        return $this->val;
    }
    /**
     * @return string
     */
    function name()
    {
        switch ($this->val) {
            case 0:
                return 'FULL';
            case 1:
                return 'LONG';
            case 2:
                return 'MEDIUM';
            case 3:
                return 'SHORT';
        }
        return '';
    }
    function __toString()
    {
        return $this->name();
    }
}
FormatStyle::init();
コード例 #3
0
 public function test_ofLocalizedDateTime2_basics()
 {
     $this->assertEquals(DateTimeFormatter::ofLocalizedDateTimeSplit(FormatStyle::FULL(), FormatStyle::MEDIUM())->getChronology(), IsoChronology::INSTANCE());
     $this->assertEquals(DateTimeFormatter::ofLocalizedDateTimeSplit(FormatStyle::FULL(), FormatStyle::MEDIUM())->getZone(), null);
     $this->assertEquals(DateTimeFormatter::ofLocalizedDateTimeSplit(FormatStyle::FULL(), FormatStyle::MEDIUM())->getResolverStyle(), ResolverStyle::SMART());
 }
コード例 #4
0
 public function test_getLocalizedLocaleNPE()
 {
     TestHelper::assertNullException($this, function () {
         DateTimeFormatterBuilder::getLocalizedDateTimePattern(FormatStyle::SHORT(), FormatStyle::SHORT(), IsoChronology::INSTANCE(), null);
     });
 }
コード例 #5
0
 /**
  * Converts the given FormatStyle to the java.text.DateFormat style.
  *
  * @param FormatStyle|null $style the FormatStyle style
  * @return int the int style, or \IntlDateFormatter::NONE if style is null, indicating un-required
  */
 private static function convertStyle($style)
 {
     if ($style === null) {
         return \IntlDateFormatter::NONE;
     }
     return $style->ordinal();
     // indices happen to align
 }
コード例 #6
0
 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()]];
 }