@ -109,6 +388,97 @@ class FormatConverterTest extends TestCase
$this->assertEquals($expected, $actual);
$this->assertEquals($expected, $actual);
}
}
public function providerForPHP2ICUPatterns()
{
return [
'single \' should be encoded as \'\', which internally should be encoded as \'\'\'\'' => ["'", "''"],
'\d' => ['\d', "'d'"],
'Day of the month, 2 digits with leading zeros 01 to 31' => ['d', 'dd'],
'\D' => ['\D', "'D'"],
'A textual representation of a day, three letters Mon through Sun' => ['D', 'eee'],
'\j' => ['\j', "'j'"],
'Day of the month without leading zeros 1 to 31' => ['j', 'd'],
'\l' => ['\l', "'l'"],
'A full textual representation of the day of the week Sunday through Saturday' => ['l', 'eeee'],
'\N' => ['\N', "'N'"],
'ISO-8601 numeric representation of the day of the week, 1 (for Monday) through 7 (for Sunday)' => ['N', 'e'],
'\S' => ['\S', "'S'"],
'English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j' => ['S', ''],
'\w' => ['\w', "'w'"],
'Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)' => ['w', ''],
'\z' => ['\z', "'z'"],
'The day of the year (starting from 0) 0 through 365' => ['z', 'D'],
'\W' => ['\W', "'W'"],
'ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year)' => ['W', 'w'],
'\F' => ['\F', "'F'"],
'A full textual representation of a month, January through December' => ['F', 'MMMM'],
'\m' => ['\m', "'m'"],
'Numeric representation of a month, with leading zeros 01 through 12' => ['m', 'MM'],
'\M' => ['\M', "'M'"],
'A short textual representation of a month, three letters Jan through Dec' => ['M', 'MMM'],
'\n' => ['\n', "'n'"],
'Numeric representation of a month, without leading zeros 1 through 12, not supported by ICU but we fallback to "with leading zero"' => ['n', 'M'],
'\t' => ['\t', "'t'"],
'Number of days in the given month 28 through 31' => ['t', ''],
'\L' => ['\L', "'L'"],
'Whether it`s a leap year, 1 if it is a leap year, 0 otherwise.' => ['L', ''],
'\o' => ['\o', "'o'"],
'ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.' => ['o', 'Y'],
'\Y' => ['\Y', "'Y'"],
'A full numeric representation of a year, 4 digits Examples: 1999 or 2003' => ['Y', 'yyyy'],
'\y' => ['\y', "'y'"],
'A two digit representation of a year Examples: 99 or 03' => ['y', 'yy'],
'\a' => ['\a', "'a'"],
'Lowercase Ante meridiem and Post meridiem, am or pm' => ['a', 'a'],
'\A' => ['\A', "'A'"],
'Uppercase Ante meridiem and Post meridiem, AM or PM, not supported by ICU but we fallback to lowercase' => ['A', 'a'],
'\B' => ['\B', "'B'"],
'\A\B' => ['\A\B', "'AB'"],
'Swatch Internet time 000 through 999' => ['B', ''],
'\g' => ['\g', "'g'"],
'12-hour format of an hour without leading zeros 1 through 12' => ['g', 'h'],
'\G' => ['\G', "'G'"],
'24-hour format of an hour without leading zeros 0 to 23h' => ['G', 'H'],
'\h' => ['\h', "'h'"],
'12-hour format of an hour with leading zeros, 01 to 12 h' => ['h', 'hh'],
'\H' => ['\H', "'H'"],
'24-hour format of an hour with leading zeros, 00 to 23 h' => ['H', 'HH'],
'\i' => ['\i', "'i'"],
'Minutes with leading zeros 00 to 59' => ['i', 'mm'],
'\s' => ['\s', "'s'"],
'Seconds, with leading zeros 00 through 59' => ['s', 'ss'],
'Whether or not the date is in daylight saving time, 1 if Daylight Saving Time, 0 otherwise.' => ['I', ''],
'\O' => ['\O', "'O'"],
'Difference to Greenwich time (GMT) in hours, Example: +0200' => ['O', 'xx'],
'\P' => ['\P', "'P'"],
'Difference to Greenwich time (GMT) with colon between hours and minutes, Example: +02:00' => ['P', 'xxx'],
'\T' => ['\T', "'T'"],
'Timezone abbreviation, Examples: EST, MDT ...' => ['T', 'zzz'],
'\Z' => ['\Z', "'Z'"],
'Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 50400' => ['Z', ''],
'\c' => ['\c', "'c'"],
'ISO 8601 date, e.g. 2004-02-12T15:19:21+00:00' => ['c', "yyyy-MM-dd'T'HH:mm:ssxxx"],
'Day of the month, 2 digits with leading zeros 01 to 31' => ['d', 'dd'],
'A textual representation of a day, three letters Mon through Sun' => ['D', 'D'],
'Day of the month without leading zeros 1 to 31' => ['j', 'd'],
'A full textual representation of the day of the week Sunday through Saturday' => ['l', 'DD'],
'ISO-8601 numeric representation of the day of the week, 1 (for Monday) through 7 (for Sunday)' => ['N', ''],
'English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j' => ['S', ''],
'Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)' => ['w', ''],
'The day of the year (starting from 0) 0 through 365' => ['z', 'o'],
'ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0) Example: 42 (the 42nd week in the year)' => ['W', ''],
'A full textual representation of a month, January through December' => ['F', 'MM'],
'Numeric representation of a month, with leading zeros 01 through 12' => ['m', 'mm'],
'A short textual representation of a month, three letters Jan through Dec' => ['M', 'M'],
'Numeric representation of a month, without leading zeros 1 through 12' => ['n', 'm'],
'Number of days in the given month 28 through 31' => ['t', ''],
'Whether it`s a leap year, 1 if it is a leap year, 0 otherwise.' => ['L', ''],
'ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.' => ['o', ''],
'A full numeric representation of a year, 4 digits Examples: 1999 or 2003' => ['Y', 'yy'],
'A two digit representation of a year Examples: 99 or 03' => ['y', 'y'],
'Lowercase Ante meridiem and Post meridiem, am or pm' => ['a', ''],
'Uppercase Ante meridiem and Post meridiem, AM or PM, not supported by ICU but we fallback to lowercase' => ['A', ''],
'Swatch Internet time 000 through 999' => ['B', ''],
'12-hour format of an hour without leading zeros 1 through 12' => ['g', ''],
'24-hour format of an hour without leading zeros 0 to 23h' => ['G', ''],
'12-hour format of an hour with leading zeros, 01 to 12 h' => ['h', ''],
'24-hour format of an hour with leading zeros, 00 to 23 h' => ['H', ''],
'Minutes with leading zeros 00 to 59' => ['i', ''],
'Seconds, with leading zeros 00 through 59' => ['s', ''],
'Whether or not the date is in daylight saving time, 1 if Daylight Saving Time, 0 otherwise.' => ['I', ''],
'Difference to Greenwich time (GMT) in hours, Example: +0200' => ['O', ''],
'Difference to Greenwich time (GMT) with colon between hours and minutes, Example: +02:00' => ['P', ''],
'Timezone abbreviation, Examples: EST, MDT ...' => ['T', ''],
'Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 50400' => ['Z', ''],
'ISO 8601 date, e.g. 2004-02-12T15:19:21+00:00, skipping the time here because it is not supported' => ['c', 'yyyy-MM-dd'],
'RFC 2822 formatted date, Example: Thu, 21 Dec 2000 16:01:07 +0200, skipping the time here because it is not supported' => ['r', 'D, d M yy'],
'Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)' => ['U', '@'],
];
}
/**
* @dataProvider providerForPHP2JUIPatterns
*/
public function testEscapedPhpToJuiSinglePattern($pattern, $expected)