Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebb43de

Browse files
committed
relax some date parser patterns
1 parent 789c330 commit ebb43de

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/Symfony/Component/Intl/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, $length)
3333
*/
3434
public function getReverseMatchingRegExp($length)
3535
{
36-
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
36+
return 1 === $length ? '\d{1,2}' : '\d{1,'.$length.'}';
3737
}
3838

3939
/**

src/Symfony/Component/Intl/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($length)
104104
$regExp = '[JFMASOND]';
105105
break;
106106
default:
107-
$regExp = '\d{'.$length.'}';
107+
$regExp = '\d{1,'.$length.'}';
108108
break;
109109
}
110110

src/Symfony/Component/Intl/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, $length)
3737
*/
3838
public function getReverseMatchingRegExp($length)
3939
{
40-
return 2 === $length ? '\d{2}' : '\d{4}';
40+
return 2 === $length ? '\d{2}' : '\d{1,4}';
4141
}
4242

4343
/**

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,12 @@ public function testGetTimeType()
548548
/**
549549
* @dataProvider parseProvider
550550
*/
551-
public function testParse($pattern, $value, $expected)
551+
public function testParse($pattern, $value, $expected, $requires64bit = false)
552552
{
553+
if ($requires64bit && PHP_INT_SIZE < 8) {
554+
$this->markTestSkipped(sprintf('Parsing "%s" requires a 64bit PHP.', $value));
555+
}
556+
553557
$errorCode = IntlGlobals::U_ZERO_ERROR;
554558
$errorMessage = 'U_ZERO_ERROR';
555559

@@ -588,6 +592,7 @@ public function parseYearProvider()
588592
return [
589593
['y-M-d', '1970-1-1', 0],
590594
['yy-M-d', '70-1-1', 0],
595+
['yyyy-M-d', '950-12-19', -32157648000, true],
591596
];
592597
}
593598

@@ -618,6 +623,7 @@ public function parseMonthProvider()
618623
{
619624
return [
620625
['y-M-d', '1970-1-1', 0],
626+
['y-MM-d', '1970-1-1', 0],
621627
['y-MMM-d', '1970-Jan-1', 0],
622628
['y-MMMM-d', '1970-January-1', 0],
623629
];
@@ -636,6 +642,7 @@ public function parseDayProvider()
636642
{
637643
return [
638644
['y-M-d', '1970-1-1', 0],
645+
['y-M-dd', '1970-1-1', 0],
639646
['y-M-dd', '1970-1-01', 0],
640647
['y-M-ddd', '1970-1-001', 0],
641648
];

0 commit comments

Comments
 (0)