public function DateTimePlusTest::providerTestTimestamp in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php \Drupal\Tests\Component\Datetime\DateTimePlusTest::providerTestTimestamp()
Provides data for testTimestamp.
Return value
array An array of arrays, each containing the arguments required for self::testTimestamp().
See also
testTimestamp()
File
- core/
tests/ Drupal/ Tests/ Component/ Datetime/ DateTimePlusTest.php, line 527
Class
- DateTimePlusTest
- @coversDefaultClass \Drupal\Component\Datetime\DateTimePlus @group Datetime
Namespace
Drupal\Tests\Component\DatetimeCode
public function providerTestTimestamp() {
return [
// Create date object from a unix timestamp and display it in
// local time.
[
'input' => 0,
'initial' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
],
'transform' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
],
],
// Create a date using the timestamp of zero, then display its
// value both in UTC and the local timezone.
[
'input' => 0,
'initial' => [
'timezone' => 'America/Los_Angeles',
'format' => 'c',
'expected_date' => '1969-12-31T16:00:00-08:00',
'expected_timezone' => 'America/Los_Angeles',
'expected_offset' => '-28800',
],
'transform' => [
'timezone' => 'UTC',
'format' => 'c',
'expected_date' => '1970-01-01T00:00:00+00:00',
'expected_timezone' => 'UTC',
'expected_offset' => 0,
],
],
];
}