You are here

public function DateApiTestCase::testDateObjectFromTimestamp in Date 7.3

Same name and namespace in other branches
  1. 7.2 date_api/tests/DateApiTestCase.test \DateApiTestCase::testDateObjectFromTimestamp()

Test creating a DateObject from a timestamp.

File

date_api/tests/DateApiTestCase.test, line 455
Test Date API functions.

Class

DateApiTestCase
Test Date API functions.

Code

public function testDateObjectFromTimestamp() {

  // Test a negative timestamp.
  $date = new \DateTime('1960-01-01');
  $obj = new DateObject($date
    ->getTimestamp(), 'UTC');
  $this
    ->assertEqual('1960-01-01', $obj
    ->format('Y-m-d'));

  // Test a positive timestamp.
  $date = new \DateTime('1980-01-01');
  $obj = new DateObject($date
    ->getTimestamp(), 'UTC');
  $this
    ->assertEqual('1980-01-01', $obj
    ->format('Y-m-d'));
}