Beispiel #1
0
 /**
  * Test for toValue
  */
 public function testToValue()
 {
     $locale = new Locale('de_AT');
     $date = new Date(1234567890, null, $locale);
     $date->setTimezone(date_default_timezone_get());
     $this->assertSame(1234567890, $date->toValue());
     $this->assertSame(14, $date->toValue(Date::DAY));
     $date->setTimezone('UTC');
     $this->assertSame(13, $date->toValue(Date::DAY));
     $this->assertFalse($date->toValue(Date::WEEKDAY_SHORT));
     $this->assertSame(13, $date->toValue(Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Date::WEEKDAY));
     $this->assertSame(5, $date->toValue(Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Date::DAY_SUFFIX));
     $this->assertSame(5, $date->toValue(Date::WEEKDAY_DIGIT));
     $this->assertSame(43, $date->toValue(Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Date::WEEK));
     $this->assertFalse($date->toValue(Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Date::MONTH));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Date::YEAR));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT_8601));
     $this->assertFalse($date->toValue(Date::MERIDIEM));
     $this->assertSame(21, $date->toValue(Date::SWATCH));
     $this->assertSame(11, $date->toValue(Date::HOUR_SHORT_AM));
     $this->assertSame(23, $date->toValue(Date::HOUR_SHORT));
     $this->assertSame(11, $date->toValue(Date::HOUR_AM));
     $this->assertSame(23, $date->toValue(Date::HOUR));
     $this->assertSame(31, $date->toValue(Date::MINUTE));
     $this->assertSame(30, $date->toValue(Date::SECOND));
     $this->assertSame(0, $date->toValue(Date::MILLISECOND));
     $this->assertSame(31, $date->toValue(Date::MINUTE_SHORT));
     $this->assertSame(30, $date->toValue(Date::SECOND_SHORT));
     $this->assertFalse($date->toValue(Date::TIMEZONE_NAME));
     $this->assertSame(0, $date->toValue(Date::DAYLIGHT));
     $this->assertSame(0, $date->toValue(Date::GMT_DIFF));
     $this->assertFalse($date->toValue(Date::GMT_DIFF_SEP));
     $this->assertFalse($date->toValue(Date::TIMEZONE));
     $this->assertSame(0, $date->toValue(Date::TIMEZONE_SECS));
     $this->assertFalse($date->toValue(Date::ISO_8601));
     $this->assertFalse($date->toValue(Date::RFC_2822));
     $this->assertSame(1234567890, $date->toValue(Date::TIMESTAMP));
     $this->assertFalse($date->toValue(Date::ERA));
     $this->assertFalse($date->toValue(Date::ERA_NAME));
     $this->assertFalse($date->toValue(Date::DATES));
     $this->assertFalse($date->toValue(Date::DATE_FULL));
     $this->assertFalse($date->toValue(Date::DATE_LONG));
     $this->assertFalse($date->toValue(Date::DATE_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATE_SHORT));
     $this->assertFalse($date->toValue(Date::TIMES));
     $this->assertFalse($date->toValue(Date::TIME_FULL));
     $this->assertFalse($date->toValue(Date::TIME_LONG));
     $this->assertFalse($date->toValue(Date::TIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::TIME_SHORT));
     $this->assertFalse($date->toValue(Date::DATETIME));
     $this->assertFalse($date->toValue(Date::DATETIME_FULL));
     $this->assertFalse($date->toValue(Date::DATETIME_LONG));
     $this->assertFalse($date->toValue(Date::DATETIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATETIME_SHORT));
     $this->assertFalse($date->toValue(Date::ATOM));
     $this->assertFalse($date->toValue(Date::COOKIE));
     $this->assertFalse($date->toValue(Date::RFC_822));
     $this->assertFalse($date->toValue(Date::RFC_850));
     $this->assertFalse($date->toValue(Date::RFC_1036));
     $this->assertFalse($date->toValue(Date::RFC_1123));
     $this->assertFalse($date->toValue(Date::RFC_3339));
     $this->assertFalse($date->toValue(Date::RSS));
     $this->assertFalse($date->toValue(Date::W3C));
     $date->setTimezone('Indian/Maldives');
     $this->assertFalse($date->toValue(Date::WEEKDAY_SHORT));
     $this->assertSame(14, $date->toValue(Date::DAY_SHORT));
     $this->assertFalse($date->toValue(Date::WEEKDAY));
     $this->assertSame(6, $date->toValue(Date::WEEKDAY_8601));
     $this->assertFalse($date->toValue(Date::DAY_SUFFIX));
     $this->assertSame(6, $date->toValue(Date::WEEKDAY_DIGIT));
     $this->assertSame(44, $date->toValue(Date::DAY_OF_YEAR));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NARROW));
     $this->assertFalse($date->toValue(Date::WEEKDAY_NAME));
     $this->assertSame(7, $date->toValue(Date::WEEK));
     $this->assertFalse($date->toValue(Date::MONTH_NAME));
     $this->assertSame(2, $date->toValue(Date::MONTH));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_SHORT));
     $this->assertSame(2, $date->toValue(Date::MONTH_SHORT));
     $this->assertSame(28, $date->toValue(Date::MONTH_DAYS));
     $this->assertFalse($date->toValue(Date::MONTH_NAME_NARROW));
     $this->assertSame(0, $date->toValue(Date::LEAPYEAR));
     $this->assertSame(2009, $date->toValue(Date::YEAR_8601));
     $this->assertSame(2009, $date->toValue(Date::YEAR));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT));
     $this->assertSame(9, $date->toValue(Date::YEAR_SHORT_8601));
     $this->assertFalse($date->toValue(Date::MERIDIEM));
     $this->assertSame(21, $date->toValue(Date::SWATCH));
     $this->assertSame(4, $date->toValue(Date::HOUR_SHORT_AM));
     $this->assertSame(4, $date->toValue(Date::HOUR_SHORT));
     $this->assertSame(4, $date->toValue(Date::HOUR_AM));
     $this->assertSame(4, $date->toValue(Date::HOUR));
     $this->assertSame(31, $date->toValue(Date::MINUTE));
     $this->assertSame(30, $date->toValue(Date::SECOND));
     $this->assertSame(0, $date->toValue(Date::MILLISECOND));
     $this->assertSame(31, $date->toValue(Date::MINUTE_SHORT));
     $this->assertSame(30, $date->toValue(Date::SECOND_SHORT));
     $this->assertFalse($date->toValue(Date::TIMEZONE_NAME));
     $this->assertSame(0, $date->toValue(Date::DAYLIGHT));
     $this->assertSame(500, $date->toValue(Date::GMT_DIFF));
     $this->assertFalse($date->toValue(Date::GMT_DIFF_SEP));
     $this->assertFalse($date->toValue(Date::TIMEZONE));
     $this->assertSame(18000, $date->toValue(Date::TIMEZONE_SECS));
     $this->assertFalse($date->toValue(Date::ISO_8601));
     $this->assertFalse($date->toValue(Date::RFC_2822));
     $this->assertSame(1234567890, $date->toValue(Date::TIMESTAMP));
     $this->assertFalse($date->toValue(Date::ERA));
     $this->assertFalse($date->toValue(Date::ERA_NAME));
     $this->assertFalse($date->toValue(Date::DATES));
     $this->assertFalse($date->toValue(Date::DATE_FULL));
     $this->assertFalse($date->toValue(Date::DATE_LONG));
     $this->assertFalse($date->toValue(Date::DATE_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATE_SHORT));
     $this->assertFalse($date->toValue(Date::TIMES));
     $this->assertFalse($date->toValue(Date::TIME_FULL));
     $this->assertFalse($date->toValue(Date::TIME_LONG));
     $this->assertFalse($date->toValue(Date::TIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::TIME_SHORT));
     $this->assertFalse($date->toValue(Date::DATETIME));
     $this->assertFalse($date->toValue(Date::DATETIME_FULL));
     $this->assertFalse($date->toValue(Date::DATETIME_LONG));
     $this->assertFalse($date->toValue(Date::DATETIME_MEDIUM));
     $this->assertFalse($date->toValue(Date::DATETIME_SHORT));
     $this->assertFalse($date->toValue(Date::ATOM));
     $this->assertFalse($date->toValue(Date::COOKIE));
     $this->assertFalse($date->toValue(Date::RFC_822));
     $this->assertFalse($date->toValue(Date::RFC_850));
     $this->assertFalse($date->toValue(Date::RFC_1036));
     $this->assertFalse($date->toValue(Date::RFC_1123));
     $this->assertFalse($date->toValue(Date::RFC_3339));
     $this->assertFalse($date->toValue(Date::RSS));
     $this->assertFalse($date->toValue(Date::W3C));
 }