function DateTimePlusTest::providerTestDateFormat

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestDateFormat()
  2. 10 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestDateFormat()
  3. 11.x core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestDateFormat()

Provides data for testDateFormats.

Return value

array An array of arrays, each containing:

  • 'input' - Input to DateTimePlus.
  • 'timezone' - Timezone for DateTimePlus.
  • 'format' - Date format for DateTimePlus.
  • 'format_date' - Date format for use in $date->format() method.
  • 'expected' - The expected return from DateTimePlus.

See also

testDateFormats()

File

core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php, line 393

Class

DateTimePlusTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Datetime%21DateTimePlus.php/class/DateTimePlus/8.9.x" title="Wraps DateTime()." class="local">\Drupal\Component\Datetime\DateTimePlus</a> @group Datetime

Namespace

Drupal\Tests\Component\Datetime

Code

public function providerTestDateFormat() {
    return [
        // Create a year-only date.
[
            '2009',
            NULL,
            'Y',
            'Y',
            '2009',
        ],
        // Create a month and year-only date.
[
            '2009-10',
            NULL,
            'Y-m',
            'Y-m',
            '2009-10',
        ],
        // Create a time-only date.
[
            'T10:30:00',
            NULL,
            '\\TH:i:s',
            'H:i:s',
            '10:30:00',
        ],
        // Create a time-only date.
[
            '10:30:00',
            NULL,
            'H:i:s',
            'H:i:s',
            '10:30:00',
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.