Skip to content

Commit 94aed33

Browse files
Merge branch '3.4' into 4.2
* 3.4: fix inline handling when dumping tagged values [PropertyAccess] Fix PropertyAccessorCollectionTest Typo in web profiler relax some date parser patterns Avoid getting right to left style
2 parents a89aa4a + 1393153 commit 94aed33

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

DateFormatter/DateFormat/DayTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function format(\DateTime $dateTime, int $length): string
3333
*/
3434
public function getReverseMatchingRegExp(int $length): string
3535
{
36-
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
36+
return 1 === $length ? '\d{1,2}' : '\d{1,'.$length.'}';
3737
}
3838

3939
/**

DateFormatter/DateFormat/MonthTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getReverseMatchingRegExp(int $length): string
104104
$regExp = '[JFMASOND]';
105105
break;
106106
default:
107-
$regExp = '\d{'.$length.'}';
107+
$regExp = '\d{1,'.$length.'}';
108108
break;
109109
}
110110

DateFormatter/DateFormat/YearTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function format(\DateTime $dateTime, int $length): string
3737
*/
3838
public function getReverseMatchingRegExp(int $length): string
3939
{
40-
return 2 === $length ? '\d{2}' : '\d{4}';
40+
return 2 === $length ? '\d{2}' : '\d{1,4}';
4141
}
4242

4343
/**

Tests/DateFormatter/AbstractIntlDateFormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ public function parseMonthProvider()
600600
{
601601
return [
602602
['y-M-d', '1970-1-1', 0],
603+
['y-MM-d', '1970-1-1', 0],
603604
['y-MMM-d', '1970-Jan-1', 0],
604605
['y-MMMM-d', '1970-January-1', 0],
605606
];
@@ -618,6 +619,7 @@ public function parseDayProvider()
618619
{
619620
return [
620621
['y-M-d', '1970-1-1', 0],
622+
['y-M-dd', '1970-1-1', 0],
621623
['y-M-dd', '1970-1-01', 0],
622624
['y-M-ddd', '1970-1-001', 0],
623625
];

Tests/DateFormatter/IntlDateFormatterTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ public function parseQuarterProvider()
183183
return $this->notImplemented(parent::parseQuarterProvider());
184184
}
185185

186+
public function testParseThreeDigitsYears()
187+
{
188+
if (PHP_INT_SIZE < 8) {
189+
$this->markTestSkipped('Parsing three digits years requires a 64bit PHP.');
190+
}
191+
192+
$formatter = $this->getDefaultDateFormatter('yyyy-M-d');
193+
$this->assertSame(-32157648000, $formatter->parse('950-12-19'));
194+
$this->assertIsIntlSuccess($formatter, 'U_ZERO_ERROR', IntlGlobals::U_ZERO_ERROR);
195+
}
196+
186197
protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
187198
{
188199
return new IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern);

0 commit comments

Comments
 (0)