Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f78a98

Browse files
committed
[Intl] handle null date and time types
1 parentf82beb5 commit9f78a98

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

‎src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class IntlDateFormatter
118118
private$timeZoneId;
119119

120120
/**
121-
* @param string $locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
122-
* @param int $datetype Type of date formatting, one of the format type constants
123-
* @param int $timetype Type of time formatting, one of the format type constants
124-
* @param mixed $timezone Timezone identifier
125-
* @param int $calendar Calendar to use for formatting or parsing. The only currently
126-
* supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
127-
* @param string $pattern Optional pattern to use when formatting
121+
* @param string$locale The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en")
122+
* @param int|null $datetype Type of date formatting, one of the format type constants
123+
* @param int|null $timetype Type of time formatting, one of the format type constants
124+
* @param mixed$timezone Timezone identifier
125+
* @param int$calendar Calendar to use for formatting or parsing. The only currently
126+
*supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
127+
* @param string$pattern Optional pattern to use when formatting
128128
*
129129
* @see http://www.php.net/manual/en/intldateformatter.create.php
130130
* @see http://userguide.icu-project.org/formatparse/datetime
@@ -144,6 +144,8 @@ public function __construct($locale, $datetype, $timetype, $timezone = null, $ca
144144

145145
$this->datetype =$datetype;
146146
$this->timetype =$timetype;
147+
$this->datetype =null !==$datetype ?$datetype :self::FULL;
148+
$this->timetype =null !==$timetype ?$timetype :self::FULL;
147149

148150
$this->setPattern($pattern);
149151
$this->setTimeZone($timezone);

‎src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ public function testConstructorDefaultTimeZone()
4646
);
4747
}
4848

49+
publicfunctiontestConstructorWithoutDateType()
50+
{
51+
$formatter =newIntlDateFormatter('en',null, IntlDateFormatter::SHORT,'UTC', IntlDateFormatter::GREGORIAN);
52+
53+
$this->assertSame('EEEE, LLLL d, y, h:mm a',$formatter->getPattern());
54+
}
55+
56+
publicfunctiontestConstructorWithoutTimeType()
57+
{
58+
$formatter =newIntlDateFormatter('en', IntlDateFormatter::SHORT,null,'UTC', IntlDateFormatter::GREGORIAN);
59+
60+
$this->assertSame('M/d/yy, h:mm:ss a zzzz',$formatter->getPattern());
61+
}
62+
4963
/**
5064
* @dataProvider formatProvider
5165
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp