public function TwigConvertTest::providerTestDateFromFormat in Twig Tools 8
Provides test data for testDateFromFormat.
Return value
array An array of test 'from' and 'to' date formats.
File
- tests/
src/ Unit/ TwigConvertTest.php, line 300
Class
- TwigConvertTest
- Tests to ensure conversions filters work correctly.
Namespace
Drupal\Tests\twig_tools\UnitCode
public function providerTestDateFromFormat() {
return [
[
"{{ '2009-Feb-15'|date_from_format('Y-M-j', 'm/d/y') }}",
"02/15/09",
],
[
"{{ '2010-04-23 10:29:35'|date_from_format('Y-m-d H:i:s', 'Y-m-d\\\\TH:i:s', 'America/New_York', 'America/New_York') }}",
"2010-04-23T10:29:35",
],
[
"{{ '2010-04-23 00:00:00'|date_from_format('Y-m-d H:i:s', 'c', 'America/New_York', 'UTC') }}",
"2010-04-23T04:00:00+00:00",
],
[
"{{ '2019-01-01 00:00:00'|date_from_format('Y-m-d H:i:s', 'Y-m-d\\\\TH:i:s', 'America/New_York', 'America/Los_Angeles') }}",
"2018-12-31T21:00:00",
],
[
"{{ '1 1 19'|date_from_format('!j n y', 'Y-m-j\\\\TH:i:s', 'America/New_York', 'America/Los_Angeles') }}",
"2018-12-31T21:00:00",
],
[
"{{ 0|date_from_format('U', 'Y-m-d') }}",
"1970-01-01",
],
[
"{{ '0'|date_from_format('U', 'Y-m-d') }}",
"1970-01-01",
],
[
"{{ '0000-00-00 00:00:00'|date_from_format('Y-m-d H:i:s', 'Y-m-d H:i:s', 'UTC', 'UTC') }}",
"-0001-11-30 00:00:00",
],
[
"{{ '01/05/1955 10:43:22'|date_from_format('m/d/Y H:i:s', 'Y-m-d\\\\TH:i:s e') }}",
"1955-01-05T10:43:22 Australia/Sydney",
],
[
"{{ '2004-11-19 10:25:33'|date_from_format('Y-m-d h:i:s', 'U', 'America/Managua') }}",
"1100881533",
],
[
"{{ '2004-12-19 10:19:42'|date_from_format('Y-m-d H:i:s', 'Y-m-d H:i:s e', NULL, 'America/Managua') }}",
"2004-12-18 17:19:42 America/Managua",
],
[
"{{ ''|date_from_format('m/d/Y', 'Y-m-d') }}",
"",
],
];
}