PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/libs/devblocks/libs/ZendFramework/Zend/Date.php

https://github.com/sluther/portsensor
PHP | 4575 lines | 2688 code | 595 blank | 1292 comment | 500 complexity | 2331206353bd2215cb10294adc82f217 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Date
  17. * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @version $Id: Date.php 6727 2007-11-03 19:29:21Z thomas $
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Include needed Date classes
  23. */
  24. require_once 'Zend/Date/DateObject.php';
  25. require_once 'Zend/Date/Exception.php';
  26. require_once 'Zend/Locale.php';
  27. require_once 'Zend/Locale/Format.php';
  28. require_once 'Zend/Locale/Math.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Date
  32. * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Date extends Zend_Date_DateObject {
  36. private $_Locale = null;
  37. // Fractional second variables
  38. private $_Fractional = 0;
  39. private $_Precision = 3;
  40. private static $_Options = array(
  41. 'format_type' => 'iso', // format for date strings 'iso' or 'php'
  42. 'fix_dst' => true, // fix dst on summer/winter time change
  43. 'extend_month' => false, // false - addMonth like SQL, true like excel
  44. 'cache' => null // cache to set
  45. );
  46. // Class wide Date Constants
  47. // day formats
  48. const DAY = 'DAY'; // d - 2 digit day of month, 01-31
  49. const DAY_SHORT = 'DAY_SHORT'; // j - 1,2 digit day of month, 1-31
  50. const DAY_SUFFIX = 'DAY_SUFFIX'; // S - english suffix day of month, st-th
  51. const DAY_OF_YEAR = 'DAY_OF_YEAR'; // z - Number of day of year
  52. const WEEKDAY = 'WEEKDAY'; // l - full day name - locale aware, Monday - Sunday
  53. const WEEKDAY_SHORT = 'WEEKDAY_SHORT'; // --- 3 letter day of week - locale aware, Mon-Sun
  54. const WEEKDAY_NARROW = 'WEEKDAY_NARROW'; // --- 1 letter day name - locale aware, M-S
  55. const WEEKDAY_NAME = 'WEEKDAY_NAME'; // D - abbreviated day name, 1-3 letters - locale aware, Mon-Sun
  56. const WEEKDAY_8601 = 'WEEKDAY_8601'; // N - digit weekday ISO 8601, 1-7 1 = monday, 7=sunday
  57. const WEEKDAY_DIGIT = 'WEEKDAY_DIGIT'; // w - weekday, 0-6 0=sunday, 6=saturday
  58. // week formats
  59. const WEEK = 'WEEK'; // W - number of week ISO8601, 1-53
  60. // month formats
  61. const MONTH = 'MONTH'; // m - 2 digit month, 01-12
  62. const MONTH_SHORT = 'MONTH_SHORT'; // n - 1 digit month, no leading zeros, 1-12
  63. const MONTH_DAYS = 'MONTH_DAYS'; // t - Number of days this month
  64. const MONTH_NAME = 'MONTH_NAME'; // F - full month name - locale aware, January-December
  65. const MONTH_NAME_SHORT = 'MONTH_NAME_SHORT'; // M - 3 letter monthname - locale aware, Jan-Dec
  66. const MONTH_NAME_NARROW = 'MONTH_NAME_NARROW'; // --- 1 letter month name - locale aware, J-D
  67. // year formats
  68. const YEAR = 'YEAR'; // Y - 4 digit year
  69. const YEAR_SHORT = 'YEAR_SHORT'; // y - 2 digit year, leading zeros 00-99
  70. const YEAR_8601 = 'YEAR_8601'; // o - number of year ISO8601
  71. const YEAR_SHORT_8601= 'YEAR_SHORT_8601';// --- 2 digit number of year ISO8601
  72. const LEAPYEAR = 'LEAPYEAR'; // L - is leapyear ?, 0-1
  73. // time formats
  74. const MERIDIEM = 'MERIDIEM'; // A,a - AM/PM - locale aware, AM/PM
  75. const SWATCH = 'SWATCH'; // B - Swatch Internet Time
  76. const HOUR = 'HOUR'; // H - 2 digit hour, leading zeros, 00-23
  77. const HOUR_SHORT = 'HOUR_SHORT'; // G - 1 digit hour, no leading zero, 0-23
  78. const HOUR_AM = 'HOUR_AM'; // h - 2 digit hour, leading zeros, 01-12 am/pm
  79. const HOUR_SHORT_AM = 'HOUR_SHORT_AM'; // g - 1 digit hour, no leading zero, 1-12 am/pm
  80. const MINUTE = 'MINUTE'; // i - 2 digit minute, leading zeros, 00-59
  81. const MINUTE_SHORT = 'MINUTE_SHORT'; // --- 1 digit minute, no leading zero, 0-59
  82. const SECOND = 'SECOND'; // s - 2 digit second, leading zeros, 00-59
  83. const SECOND_SHORT = 'SECOND_SHORT'; // --- 1 digit second, no leading zero, 0-59
  84. const MILLISECOND = 'MILLISECOND'; // --- milliseconds
  85. // timezone formats
  86. const TIMEZONE_NAME = 'TIMEZONE_NAME'; // e - timezone string
  87. const DAYLIGHT = 'DAYLIGHT'; // I - is Daylight saving time ?, 0-1
  88. const GMT_DIFF = 'GMT_DIFF'; // O - GMT difference, -1200 +1200
  89. const GMT_DIFF_SEP = 'GMT_DIFF_SEP'; // P - seperated GMT diff, -12:00 +12:00
  90. const TIMEZONE = 'TIMEZONE'; // T - timezone, EST, GMT, MDT
  91. const TIMEZONE_SECS = 'TIMEZONE_SECS'; // Z - timezone offset in seconds, -43200 +43200
  92. // date strings
  93. const ISO_8601 = 'ISO_8601'; // c - ISO 8601 date string
  94. const RFC_2822 = 'RFC_2822'; // r - RFC 2822 date string
  95. const TIMESTAMP = 'TIMESTAMP'; // U - unix timestamp
  96. // additional formats
  97. const ERA = 'ERA'; // --- short name of era, locale aware,
  98. const ERA_NAME = 'ERA_NAME'; // --- full name of era, locale aware,
  99. const DATES = 'DATES'; // --- standard date, locale aware
  100. const DATE_FULL = 'DATE_FULL'; // --- full date, locale aware
  101. const DATE_LONG = 'DATE_LONG'; // --- long date, locale aware
  102. const DATE_MEDIUM = 'DATE_MEDIUM'; // --- medium date, locale aware
  103. const DATE_SHORT = 'DATE_SHORT'; // --- short date, locale aware
  104. const TIMES = 'TIMES'; // --- standard time, locale aware
  105. const TIME_FULL = 'TIME_FULL'; // --- full time, locale aware
  106. const TIME_LONG = 'TIME_LONG'; // --- long time, locale aware
  107. const TIME_MEDIUM = 'TIME_MEDIUM'; // --- medium time, locale aware
  108. const TIME_SHORT = 'TIME_SHORT'; // --- short time, locale aware
  109. const ATOM = 'ATOM'; // --- DATE_ATOM
  110. const COOKIE = 'COOKIE'; // --- DATE_COOKIE
  111. const RFC_822 = 'RFC_822'; // --- DATE_RFC822
  112. const RFC_850 = 'RFC_850'; // --- DATE_RFC850
  113. const RFC_1036 = 'RFC_1036'; // --- DATE_RFC1036
  114. const RFC_1123 = 'RFC_1123'; // --- DATE_RFC1123
  115. const RFC_3339 = 'RFC_3339'; // --- DATE_RFC3339
  116. const RSS = 'RSS'; // --- DATE_RSS
  117. const W3C = 'W3C'; // --- DATE_W3C
  118. /**
  119. * Generates the standard date object, could be a unix timestamp, localized date,
  120. * string, integer, array and so on. Also parts of dates or time are supported
  121. * Always set the default timezone: http://php.net/date_default_timezone_set
  122. * For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles');
  123. * For detailed instructions please look in the docu.
  124. *
  125. * @param string|integer|Zend_Date|array $date OPTIONAL Date value or value of date part to set
  126. * ,depending on $part. If null the actual time is set
  127. * @param string $part OPTIONAL Defines the input format of $date
  128. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  129. * @return Zend_Date
  130. * @throws Zend_Date_Exception
  131. */
  132. public function __construct($date = null, $part = null, $locale = null)
  133. {
  134. if (Zend_Locale::isLocale($date)) {
  135. $locale = $date;
  136. $date = null;
  137. $part = null;
  138. } else if (Zend_Locale::isLocale($part)) {
  139. $locale = $part;
  140. $part = null;
  141. }
  142. $this->setLocale($locale);
  143. // set the timezone and offset for $this
  144. $zone = @date_default_timezone_get();
  145. $this->setTimezone($zone);
  146. if (is_string($date) && defined("self::".$date)) {
  147. $part = $date;
  148. $date = null;
  149. }
  150. if (is_null($date)) {
  151. $date = Zend_Date::now();
  152. if (($part !== null) && ($part !== Zend_Date::TIMESTAMP)) {
  153. $date = $date->get($part);
  154. }
  155. }
  156. if (($date instanceof Zend_TimeSync_Ntp) or
  157. ($date instanceof Zend_TimeSync_Sntp)) {
  158. $date = $date->getInfo();
  159. $date = $this->_getTime($date['offset']);
  160. $part = null;
  161. }
  162. // set datepart
  163. if (($part !== null && $part !== Zend_Date::TIMESTAMP) or (!is_numeric($date))) {
  164. // switch off dst handling for value setting
  165. $this->setUnixTimestamp($this->getGmtOffset());
  166. $this->set($date, $part, $this->_Locale);
  167. // DST fix
  168. if (is_array($date) and array_key_exists('hour', $date)) {
  169. $hour = $this->toString('H');
  170. $hour = $date['hour'] - $hour;
  171. if ($hour !== 0) {
  172. $this->addTimestamp($hour * 3600);
  173. }
  174. }
  175. } else {
  176. $this->setUnixTimestamp($date);
  177. }
  178. }
  179. /**
  180. * Sets class wide options, if no option was given, the actual set options will be returned
  181. *
  182. * @param array $options Options to set
  183. * @throws Zend_Date_Exception
  184. * @return Options array if no option was given
  185. */
  186. public static function setOptions(array $options = array())
  187. {
  188. if (empty($options)) {
  189. return self::$_Options;
  190. }
  191. foreach ($options as $name => $value) {
  192. $name = strtolower($name);
  193. if (array_key_exists($name, self::$_Options)) {
  194. switch($name) {
  195. case 'format_type' :
  196. if ((strtolower($value) != 'php') && (strtolower($value) != 'iso')) {
  197. throw new Zend_Date_Exception("Unknown format type ($value) for dates, only 'iso' and 'php' supported", $value);
  198. }
  199. break;
  200. case 'fix_dst' :
  201. if (!is_bool($value)) {
  202. throw new Zend_Date_Exception("'fix_dst' has to be boolean", $value);
  203. }
  204. break;
  205. case 'extend_month' :
  206. if (!is_bool($value)) {
  207. throw new Zend_Date_Exception("'extend_month' has to be boolean", $value);
  208. }
  209. break;
  210. case 'cache' :
  211. if (!$value instanceof Zend_Cache_Core) {
  212. throw new Zend_Date_Exception("Instance of Zend_Cache expected");
  213. }
  214. parent::$_cache = $value;
  215. Zend_Locale_Data::setCache($value);
  216. break;
  217. }
  218. self::$_Options[$name] = $value;
  219. }
  220. else {
  221. throw new Zend_Date_Exception("Unknown option: $name = $value");
  222. }
  223. }
  224. }
  225. /**
  226. * Returns this object's internal UNIX timestamp (equivalent to Zend_Date::TIMESTAMP).
  227. * If the timestamp is too large for integers, then the return value will be a string.
  228. * This function does not return the timestamp as an object.
  229. * Use clone() or copyPart() instead.
  230. *
  231. * @return integer|string UNIX timestamp
  232. */
  233. public function getTimestamp()
  234. {
  235. return $this->getUnixTimestamp();
  236. }
  237. /**
  238. * Returns the calculated timestamp
  239. * HINT: timestamps are always GMT
  240. *
  241. * @param string $calc Type of calculation to make
  242. * @param string|integer|array|Zend_Date $stamp Timestamp to calculate, when null the actual timestamp is calculated
  243. * @return Zend_Date|integer
  244. * @throws Zend_Date_Exception
  245. */
  246. private function _timestamp($calc, $stamp)
  247. {
  248. if ($stamp instanceof Zend_Date) {
  249. // extract timestamp from object
  250. $stamp = $stamp->get(Zend_Date::TIMESTAMP, true);
  251. }
  252. if (is_array($stamp)) {
  253. if (array_key_exists('timestamp', $stamp)) {
  254. $stamp = $stamp['timestamp'];
  255. } else {
  256. throw new Zend_Date_Exception('no timestamp given in array');
  257. }
  258. }
  259. if ($calc === 'set') {
  260. $return = $this->setUnixTimestamp($stamp);
  261. } else {
  262. $return = $this->_calcdetail($calc, $stamp, Zend_Date::TIMESTAMP, null);
  263. }
  264. if ($calc != 'cmp') {
  265. return $this;
  266. }
  267. return $return;
  268. }
  269. /**
  270. * Sets a new timestamp
  271. *
  272. * @param integer|string|array|Zend_Date $timestamp Timestamp to set
  273. * @return Zend_Date
  274. * @throws Zend_Date_Exception
  275. */
  276. public function setTimestamp($timestamp)
  277. {
  278. return $this->_timestamp('set', $timestamp);
  279. }
  280. /**
  281. * Adds a timestamp
  282. *
  283. * @param integer|string|array|Zend_Date $timestamp Timestamp to add
  284. * @return Zend_Date
  285. * @throws Zend_Date_Exception
  286. */
  287. public function addTimestamp($timestamp)
  288. {
  289. return $this->_timestamp('add', $timestamp);
  290. }
  291. /**
  292. * Subtracts a timestamp
  293. *
  294. * @param integer|string|array|Zend_Date $timestamp Timestamp to sub
  295. * @return Zend_Date
  296. * @throws Zend_Date_Exception
  297. */
  298. public function subTimestamp($timestamp)
  299. {
  300. return $this->_timestamp('sub', $timestamp);
  301. }
  302. /**
  303. * Compares two timestamps, returning the difference as integer
  304. *
  305. * @param integer|string|array|Zend_Date $timestamp Timestamp to compare
  306. * @return integer 0 = equal, 1 = later, -1 = earlier
  307. * @throws Zend_Date_Exception
  308. */
  309. public function compareTimestamp($timestamp)
  310. {
  311. return $this->_timestamp('cmp', $timestamp);
  312. }
  313. /**
  314. * Returns a string representation of the object
  315. * Supported format tokens are:
  316. * G - era, y - year, Y - ISO year, M - month, w - week of year, D - day of year, d - day of month
  317. * E - day of week, e - number of weekday (1-7), h - hour 1-12, H - hour 0-23, m - minute, s - second
  318. * A - milliseconds of day, z - timezone, Z - timezone offset, S - fractional second, a - period of day
  319. *
  320. * Additionally format tokens but non ISO conform are:
  321. * SS - day suffix, eee - php number of weekday(0-6), ddd - number of days per month
  322. * l - Leap year, B - swatch internet time, I - daylight saving time, X - timezone offset in seconds
  323. * r - RFC2822 format, U - unix timestamp
  324. *
  325. * Not supported ISO tokens are
  326. * u - extended year, Q - quarter, q - quarter, L - stand alone month, W - week of month
  327. * F - day of week of month, g - modified julian, c - stand alone weekday, k - hour 0-11, K - hour 1-24
  328. * v - wall zone
  329. *
  330. * @param string $format OPTIONAL Rule for formatting output. If null the default date format is used
  331. * @param string $type OPTIONAL Type for the format string which overrides the standard setting
  332. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  333. * @return string
  334. */
  335. public function toString($format = null, $type = null, $locale = null)
  336. {
  337. if ((strlen($format) != 2) and (Zend_Locale::isLocale($format))) {
  338. $locale = $format;
  339. $format = null;
  340. }
  341. if (Zend_Locale::isLocale($type)) {
  342. $locale = $type;
  343. $type = null;
  344. }
  345. if ($locale === null) {
  346. $locale = $this->getLocale();
  347. }
  348. if ($format === null) {
  349. $format = Zend_Locale_Format::getDateFormat($locale) . ' ' . Zend_Locale_Format::getTimeFormat($locale);
  350. } else if (((self::$_Options['format_type'] == 'php') && ($type === null)) or ($type == 'php')) {
  351. $format = Zend_Locale_Format::convertPhpToIsoFormat($format);
  352. }
  353. // get format tokens
  354. $j = 0;
  355. $comment = false;
  356. $output = array();
  357. for($i = 0; $i < strlen($format); ++$i) {
  358. if ($format[$i] == "'") {
  359. if ($comment == false) {
  360. $comment = true;
  361. ++$j;
  362. $output[$j] = "'";
  363. } else if (isset($format[$i+1]) and ($format[$i+1] == "'")) {
  364. $output[$j] .= "'";
  365. ++$i;
  366. } else {
  367. $comment = false;
  368. }
  369. continue;
  370. }
  371. if (isset($output[$j]) and ($output[$j][0] == $format[$i]) or
  372. ($comment == true)) {
  373. $output[$j] .= $format[$i];
  374. } else {
  375. ++$j;
  376. $output[$j] = $format[$i];
  377. }
  378. }
  379. $notset = false;
  380. // fill format tokens with date information
  381. for($i = 1; $i <= count($output); ++$i) {
  382. // fill fixed tokens
  383. switch ($output[$i]) {
  384. // special formats
  385. case 'SS' :
  386. $output[$i] = $this->date('S', $this->getUnixTimestamp(), false);
  387. break;
  388. case 'eee' :
  389. $output[$i] = $this->date('N', $this->getUnixTimestamp(), false);
  390. break;
  391. case 'ddd' :
  392. $output[$i] = $this->date('t', $this->getUnixTimestamp(), false);
  393. break;
  394. case 'l' :
  395. $output[$i] = $this->date('L', $this->getUnixTimestamp(), false);
  396. break;
  397. case 'B' :
  398. $output[$i] = $this->date('B', $this->getUnixTimestamp(), false);
  399. break;
  400. case 'I' :
  401. $output[$i] = $this->date('I', $this->getUnixTimestamp(), false);
  402. break;
  403. case 'X' :
  404. $output[$i] = $this->date('Z', $this->getUnixTimestamp(), false);
  405. break;
  406. case 'r' :
  407. $output[$i] = $this->date('r', $this->getUnixTimestamp(), false);
  408. break;
  409. case 'U' :
  410. $output[$i] = $this->getUnixTimestamp();
  411. break;
  412. // eras
  413. case 'GGGGG' :
  414. $output[$i] = substr($this->get(Zend_Date::ERA, $locale), 0, 1) . ".";
  415. break;
  416. case 'GGGG' :
  417. $output[$i] = $this->get(Zend_Date::ERA_NAME, $locale);
  418. break;
  419. case 'GGG' :
  420. case 'GG' :
  421. case 'G' :
  422. $output[$i] = $this->get(Zend_Date::ERA, $locale);
  423. break;
  424. // years
  425. case 'yy' :
  426. $output[$i] = str_pad($this->get(Zend_Date::YEAR_SHORT, $locale), 2, '0', STR_PAD_LEFT);
  427. break;
  428. // ISO years
  429. case 'YY' :
  430. $output[$i] = str_pad($this->get(Zend_Date::YEAR_SHORT_8601, $locale), 2, '0', STR_PAD_LEFT);
  431. break;
  432. // months
  433. case 'MMMMM' :
  434. $output[$i] = substr($this->get(Zend_Date::MONTH_NAME_NARROW, $locale), 0, 1);
  435. break;
  436. case 'MMMM' :
  437. $output[$i] = $this->get(Zend_Date::MONTH_NAME, $locale);
  438. break;
  439. case 'MMM' :
  440. $output[$i] = $this->get(Zend_Date::MONTH_NAME_SHORT, $locale);
  441. break;
  442. case 'MM' :
  443. $output[$i] = $this->get(Zend_Date::MONTH, $locale);
  444. break;
  445. case 'M' :
  446. $output[$i] = $this->get(Zend_Date::MONTH_SHORT, $locale);
  447. break;
  448. // week
  449. case 'ww' :
  450. $output[$i] = str_pad($this->get(Zend_Date::WEEK, $locale), 2, '0', STR_PAD_LEFT);
  451. break;
  452. case 'w' :
  453. $output[$i] = $this->get(Zend_Date::WEEK, $locale);
  454. break;
  455. // monthday
  456. case 'dd' :
  457. $output[$i] = $this->get(Zend_Date::DAY, $locale);
  458. break;
  459. case 'd' :
  460. $output[$i] = $this->get(Zend_Date::DAY_SHORT, $locale);
  461. break;
  462. // yearday
  463. case 'DDD' :
  464. $output[$i] = str_pad($this->get(Zend_Date::DAY_OF_YEAR, $locale), 3, '0', STR_PAD_LEFT);
  465. break;
  466. case 'DD' :
  467. $output[$i] = str_pad($this->get(Zend_Date::DAY_OF_YEAR, $locale), 2, '0', STR_PAD_LEFT);
  468. break;
  469. case 'D' :
  470. $output[$i] = $this->get(Zend_Date::DAY_OF_YEAR, $locale);
  471. break;
  472. // weekday
  473. case 'EEEEE' :
  474. $output[$i] = $this->get(Zend_Date::WEEKDAY_NARROW, $locale);
  475. break;
  476. case 'EEEE' :
  477. $output[$i] = $this->get(Zend_Date::WEEKDAY, $locale);
  478. break;
  479. case 'EEE' :
  480. $output[$i] = $this->get(Zend_Date::WEEKDAY_SHORT, $locale);
  481. break;
  482. case 'EE' :
  483. $output[$i] = $this->get(Zend_Date::WEEKDAY_NAME, $locale);
  484. break;
  485. case 'E' :
  486. $output[$i] = $this->get(Zend_Date::WEEKDAY_NARROW, $locale);
  487. break;
  488. // weekday number
  489. case 'ee' :
  490. $output[$i] = str_pad($this->get(Zend_Date::WEEKDAY_8601, $locale), 2, '0', STR_PAD_LEFT);
  491. break;
  492. case 'e' :
  493. $output[$i] = $this->get(Zend_Date::WEEKDAY_8601, $locale);
  494. break;
  495. // period
  496. case 'a' :
  497. $output[$i] = $this->get(Zend_Date::MERIDIEM, $locale);
  498. break;
  499. // hour
  500. case 'hh' :
  501. $output[$i] = $this->get(Zend_Date::HOUR_AM, $locale);
  502. break;
  503. case 'h' :
  504. $output[$i] = $this->get(Zend_Date::HOUR_SHORT_AM, $locale);
  505. break;
  506. case 'HH' :
  507. $output[$i] = $this->get(Zend_Date::HOUR, $locale);
  508. break;
  509. case 'H' :
  510. $output[$i] = $this->get(Zend_Date::HOUR_SHORT, $locale);
  511. break;
  512. // minute
  513. case 'mm' :
  514. $output[$i] = $this->get(Zend_Date::MINUTE, $locale);
  515. break;
  516. case 'm' :
  517. $output[$i] = $this->get(Zend_Date::MINUTE_SHORT, $locale);
  518. break;
  519. // second
  520. case 'ss' :
  521. $output[$i] = $this->get(Zend_Date::SECOND, $locale);
  522. break;
  523. case 's' :
  524. $output[$i] = $this->get(Zend_Date::SECOND_SHORT, $locale);
  525. break;
  526. case 'S' :
  527. $output[$i] = $this->get(Zend_Date::MILLISECOND, $locale);
  528. break;
  529. // zone
  530. // @todo: v needs to be reworked as it's the long wall time and not the timezone
  531. case 'vvvv' :
  532. case 'zzzz' :
  533. $output[$i] = $this->get(Zend_Date::TIMEZONE_NAME, $locale);
  534. break;
  535. // @todo: v needs to be reworked as it's the short wall time and not the timezone
  536. case 'v' :
  537. case 'zzz' :
  538. case 'zz' :
  539. case 'z' :
  540. $output[$i] = $this->get(Zend_Date::TIMEZONE, $locale);
  541. break;
  542. // zone offset
  543. case 'ZZZZ' :
  544. $output[$i] = $this->get(Zend_Date::GMT_DIFF_SEP, $locale);
  545. break;
  546. case 'ZZZ' :
  547. case 'ZZ' :
  548. case 'Z' :
  549. $output[$i] = $this->get(Zend_Date::GMT_DIFF, $locale);
  550. break;
  551. default :
  552. $notset = true;
  553. break;
  554. }
  555. // fill variable tokens
  556. if ($notset == true) {
  557. if (($output[$i][0] !== "'") and (preg_match('/y+/', $output[$i]))) {
  558. $length = strlen($output[$i]);
  559. $output[$i] = $this->get(Zend_Date::YEAR, $locale);
  560. $output[$i] = str_pad($output[$i], $length, '0', STR_PAD_LEFT);
  561. }
  562. if (($output[$i][0] !== "'") and (preg_match('/Y+/', $output[$i]))) {
  563. $length = strlen($output[$i]);
  564. $output[$i] = $this->get(Zend_Date::YEAR_8601, $locale);
  565. $output[$i] = str_pad($output[$i], $length, '0', STR_PAD_LEFT);
  566. }
  567. if (($output[$i][0] !== "'") and (preg_match('/A+/', $output[$i]))) {
  568. $length = strlen($output[$i]);
  569. $seconds = $this->get(Zend_Date::TIMESTAMP, $locale);
  570. $month = $this->get(Zend_Date::MONTH_SHORT, $locale);
  571. $day = $this->get(Zend_Date::DAY_SHORT, $locale);
  572. $year = $this->get(Zend_Date::YEAR, $locale);
  573. $seconds -= $this->mktime(0, 0, 0, $month, $day, $year, false);
  574. $output[$i] = str_pad($seconds, $length, '0', STR_PAD_LEFT);
  575. }
  576. if ($output[$i][0] === "'") {
  577. $output[$i] = substr($output[$i], 1);
  578. }
  579. }
  580. $notset = false;
  581. }
  582. return implode('', $output);
  583. }
  584. /**
  585. * Returns a string representation of the date which is equal with the timestamp
  586. *
  587. * @return string
  588. */
  589. public function __toString()
  590. {
  591. return $this->toString(null, $this->_Locale);
  592. }
  593. /**
  594. * Returns a integer representation of the object
  595. * But returns false when the given part is no value f.e. Month-Name
  596. *
  597. * @param string|integer|Zend_Date $part OPTIONAL Defines the date or datepart to return as integer
  598. * @return integer|false
  599. */
  600. public function toValue($part = null)
  601. {
  602. $result = $this->get($part);
  603. if (is_numeric($result)) {
  604. return intval("$result");
  605. } else {
  606. return false;
  607. }
  608. }
  609. /**
  610. * Returns an array representation of the object
  611. *
  612. * @return array
  613. */
  614. public function toArray()
  615. {
  616. return array('day' => $this->get(Zend_Date::DAY_SHORT),
  617. 'month' => $this->get(Zend_Date::MONTH_SHORT),
  618. 'year' => $this->get(Zend_Date::YEAR),
  619. 'hour' => $this->get(Zend_Date::HOUR_SHORT),
  620. 'minute' => $this->get(Zend_Date::MINUTE_SHORT),
  621. 'second' => $this->get(Zend_Date::SECOND_SHORT),
  622. 'timezone' => $this->get(Zend_Date::TIMEZONE),
  623. 'timestamp' => $this->get(Zend_Date::TIMESTAMP),
  624. 'weekday' => $this->get(Zend_Date::WEEKDAY_DIGIT),
  625. 'dayofyear' => $this->get(Zend_Date::DAY_OF_YEAR),
  626. 'week' => $this->get(Zend_Date::WEEK),
  627. 'gmtsecs' => $this->get(Zend_Date::TIMEZONE_SECS));
  628. }
  629. /**
  630. * Returns a representation of a date or datepart
  631. * This could be for example a localized monthname, the time without date,
  632. * the era or only the fractional seconds. There are about 50 different supported date parts.
  633. * For a complete list of supported datepart values look into the docu
  634. *
  635. * @param string $part OPTIONAL Part of the date to return, if null the timestamp is returned
  636. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  637. * @return integer|string date or datepart
  638. */
  639. public function get($part = null, $locale = null)
  640. {
  641. if ($locale === null) {
  642. $locale = $this->getLocale();
  643. }
  644. if (Zend_Locale::isLocale($part)) {
  645. $locale = $part;
  646. $part = null;
  647. }
  648. if ($part === null) {
  649. $part = Zend_Date::TIMESTAMP;
  650. }
  651. if (!defined("self::".$part)) {
  652. return $this->toString($part, $locale);
  653. }
  654. switch($part) {
  655. // day formats
  656. case Zend_Date::DAY :
  657. return $this->date('d', $this->getUnixTimestamp(), false);
  658. break;
  659. case Zend_Date::WEEKDAY_SHORT :
  660. $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
  661. $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday));
  662. return substr($day[$weekday], 0, 3);
  663. break;
  664. case Zend_Date::DAY_SHORT :
  665. return $this->date('j', $this->getUnixTimestamp(), false);
  666. break;
  667. case Zend_Date::WEEKDAY :
  668. $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
  669. $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'wide', $weekday));
  670. return $day[$weekday];
  671. break;
  672. case Zend_Date::WEEKDAY_8601 :
  673. return $this->date('N', $this->getUnixTimestamp(), false);
  674. break;
  675. case Zend_Date::DAY_SUFFIX :
  676. return $this->date('S', $this->getUnixTimestamp(), false);
  677. break;
  678. case Zend_Date::WEEKDAY_DIGIT :
  679. return $this->date('w', $this->getUnixTimestamp(), false);
  680. break;
  681. case Zend_Date::DAY_OF_YEAR :
  682. return $this->date('z', $this->getUnixTimestamp(), false);
  683. break;
  684. case Zend_Date::WEEKDAY_NARROW :
  685. $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
  686. $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday));
  687. return substr($day[$weekday], 0, 1);
  688. break;
  689. case Zend_Date::WEEKDAY_NAME :
  690. $weekday = strtolower($this->date('D', $this->getUnixTimestamp(), false));
  691. $day = Zend_Locale_Data::getContent($locale, 'day', array('gregorian', 'format', 'abbreviated', $weekday));
  692. return $day[$weekday];
  693. break;
  694. // week formats
  695. case Zend_Date::WEEK :
  696. return $this->date('W', $this->getUnixTimestamp(), false);
  697. break;
  698. // month formats
  699. case Zend_Date::MONTH_NAME :
  700. $month = $this->date('n', $this->getUnixTimestamp(), false);
  701. $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'wide', $month));
  702. return $mon[$month];
  703. break;
  704. case Zend_Date::MONTH :
  705. return $this->date('m', $this->getUnixTimestamp(), false);
  706. break;
  707. case Zend_Date::MONTH_NAME_SHORT :
  708. $month = $this->date('n', $this->getUnixTimestamp(), false);
  709. $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month));
  710. return $mon[$month];
  711. break;
  712. case Zend_Date::MONTH_SHORT :
  713. return $this->date('n', $this->getUnixTimestamp(), false);
  714. break;
  715. case Zend_Date::MONTH_DAYS :
  716. return $this->date('t', $this->getUnixTimestamp(), false);
  717. break;
  718. case Zend_Date::MONTH_NAME_NARROW :
  719. $month = $this->date('n', $this->getUnixTimestamp(), false);
  720. $mon = Zend_Locale_Data::getContent($locale, 'month', array('gregorian', 'format', 'abbreviated', $month));
  721. return substr($mon[$month], 0, 1);
  722. break;
  723. // year formats
  724. case Zend_Date::LEAPYEAR :
  725. return $this->date('L', $this->getUnixTimestamp(), false);
  726. break;
  727. case Zend_Date::YEAR_8601 :
  728. return $this->date('o', $this->getUnixTimestamp(), false);
  729. break;
  730. case Zend_Date::YEAR :
  731. return $this->date('Y', $this->getUnixTimestamp(), false);
  732. break;
  733. case Zend_Date::YEAR_SHORT :
  734. return $this->date('y', $this->getUnixTimestamp(), false);
  735. break;
  736. case Zend_Date::YEAR_SHORT_8601 :
  737. $year = $this->date('o', $this->getUnixTimestamp(), false);
  738. return substr($year, -2);
  739. break;
  740. // time formats
  741. case Zend_Date::MERIDIEM :
  742. $am = $this->date('a', $this->getUnixTimestamp(), false);
  743. $amlocal = Zend_Locale_Data::getContent($locale, 'daytime', 'gregorian');
  744. return $amlocal[$am];
  745. break;
  746. case Zend_Date::SWATCH :
  747. return $this->date('B', $this->getUnixTimestamp(), false);
  748. break;
  749. case Zend_Date::HOUR_SHORT_AM :
  750. return $this->date('g', $this->getUnixTimestamp(), false);
  751. break;
  752. case Zend_Date::HOUR_SHORT :
  753. return $this->date('G', $this->getUnixTimestamp(), false);
  754. break;
  755. case Zend_Date::HOUR_AM :
  756. return $this->date('h', $this->getUnixTimestamp(), false);
  757. break;
  758. case Zend_Date::HOUR :
  759. return $this->date('H', $this->getUnixTimestamp(), false);
  760. break;
  761. case Zend_Date::MINUTE :
  762. return $this->date('i', $this->getUnixTimestamp(), false);
  763. break;
  764. case Zend_Date::SECOND :
  765. return $this->date('s', $this->getUnixTimestamp(), false);
  766. break;
  767. case Zend_Date::MINUTE_SHORT :
  768. return $this->date('i', $this->getUnixTimestamp(), false);
  769. break;
  770. case Zend_Date::SECOND_SHORT :
  771. return $this->date('s', $this->getUnixTimestamp(), false);
  772. break;
  773. case Zend_Date::MILLISECOND :
  774. return $this->_Fractional;
  775. break;
  776. // timezone formats
  777. case Zend_Date::TIMEZONE_NAME :
  778. return $this->date('e', $this->getUnixTimestamp(), false);
  779. break;
  780. case Zend_Date::DAYLIGHT :
  781. return $this->date('I', $this->getUnixTimestamp(), false);
  782. break;
  783. case Zend_Date::GMT_DIFF :
  784. return $this->date('O', $this->getUnixTimestamp(), false);
  785. break;
  786. case Zend_Date::GMT_DIFF_SEP :
  787. return $this->date('P', $this->getUnixTimestamp(), false);
  788. break;
  789. case Zend_Date::TIMEZONE :
  790. return $this->date('T', $this->getUnixTimestamp(), false);
  791. break;
  792. case Zend_Date::TIMEZONE_SECS :
  793. return $this->date('Z', $this->getUnixTimestamp(), false);
  794. break;
  795. // date strings
  796. case Zend_Date::ISO_8601 :
  797. return $this->date('c', $this->getUnixTimestamp(), false);
  798. break;
  799. case Zend_Date::RFC_2822 :
  800. return $this->date('r', $this->getUnixTimestamp(), false);
  801. break;
  802. case Zend_Date::TIMESTAMP :
  803. return $this->getUnixTimestamp();
  804. break;
  805. // additional formats
  806. case Zend_Date::ERA :
  807. $year = $this->date('Y', $this->getUnixTimestamp(), false);
  808. if ($year < 0) {
  809. $era = Zend_Locale_Data::getContent($locale, 'erashort', array('gregorian', '0'));
  810. return $era['0'];
  811. }
  812. $era = Zend_Locale_Data::getContent($locale, 'erashort', array('gregorian', '1'));
  813. return $era['1'];
  814. break;
  815. case Zend_Date::ERA_NAME :
  816. $year = $this->date('Y', $this->getUnixTimestamp(), false);
  817. if ($year < 0) {
  818. $era = Zend_Locale_Data::getContent($locale, 'era', array('gregorian', '0'));
  819. return $era['0'];
  820. }
  821. $era = Zend_Locale_Data::getContent($locale, 'era', array('gregorian', '1'));
  822. if (!isset($era['1'])) {
  823. return false;
  824. }
  825. return $era['1'];
  826. break;
  827. case Zend_Date::DATES :
  828. return $this->toString(Zend_Locale_Format::getDateFormat($locale), 'iso', $locale);
  829. break;
  830. case Zend_Date::DATE_FULL :
  831. $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'full'));
  832. return $this->toString($date['pattern'], 'iso', $locale);
  833. break;
  834. case Zend_Date::DATE_LONG :
  835. $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'long'));
  836. return $this->toString($date['pattern'], 'iso', $locale);
  837. break;
  838. case Zend_Date::DATE_MEDIUM :
  839. $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'medium'));
  840. return $this->toString($date['pattern'], 'iso', $locale);
  841. break;
  842. case Zend_Date::DATE_SHORT :
  843. $date = Zend_Locale_Data::getContent($locale, 'dateformat', array('gregorian', 'short'));
  844. return $this->toString($date['pattern'], 'iso', $locale);
  845. break;
  846. case Zend_Date::TIMES :
  847. return $this->toString(Zend_Locale_Format::getTimeFormat($locale), 'iso', $locale);
  848. break;
  849. case Zend_Date::TIME_FULL :
  850. $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'full'));
  851. return $this->toString($time['pattern'], 'iso', $locale);
  852. break;
  853. case Zend_Date::TIME_LONG :
  854. $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'long'));
  855. return $this->toString($time['pattern'], 'iso', $locale);
  856. break;
  857. case Zend_Date::TIME_MEDIUM :
  858. $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'medium'));
  859. return $this->toString($time['pattern'], 'iso', $locale);
  860. break;
  861. case Zend_Date::TIME_SHORT :
  862. $time = Zend_Locale_Data::getContent($locale, 'timeformat', array('gregorian', 'short'));
  863. return $this->toString($time['pattern'], 'iso', $locale);
  864. break;
  865. case Zend_Date::ATOM :
  866. return $this->date('Y\-m\-d\TH\:i\:sP', $this->getUnixTimestamp(), false);
  867. break;
  868. case Zend_Date::COOKIE :
  869. return $this->date('l\, d\-M\-y H\:i\:s e', $this->getUnixTimestamp(), false);
  870. break;
  871. case Zend_Date::RFC_822 :
  872. return $this->date('D\, d M y H\:i\:s O', $this->getUnixTimestamp(), false);
  873. break;
  874. case Zend_Date::RFC_850 :
  875. return $this->date('l\, d\-M\-y H\:i\:s e', $this->getUnixTimestamp(), false);
  876. break;
  877. case Zend_Date::RFC_1036 :
  878. return $this->date('D\, d M y H\:i\:s O', $this->getUnixTimestamp(), false);
  879. break;
  880. case Zend_Date::RFC_1123 :
  881. return $this->date('D\, d M Y H\:i\:s O', $this->getUnixTimestamp(), false);
  882. break;
  883. case Zend_Date::RFC_3339 :
  884. return $this->date('Y\-m\-d\TH\:i\:sP', $this->getUnixTimestamp(), false);
  885. break;
  886. case Zend_Date::RSS :
  887. return $this->date('D\, d M Y H\:i\:s O', $this->getUnixTimestamp(), false);
  888. break;
  889. case Zend_Date::W3C :
  890. return $this->date('Y\-m\-d\TH\:i\:sP', $this->getUnixTimestamp(), false);
  891. break;
  892. }
  893. }
  894. /**
  895. * Return digit from standard names (english)
  896. * Faster implementation than locale aware searching
  897. *
  898. * @param string $name
  899. * @return integer Number of this month
  900. * @throws Zend_Date_Exception
  901. */
  902. private function getDigitFromName($name)
  903. {
  904. switch($name) {
  905. case "Jan":
  906. return 1;
  907. case "Feb":
  908. return 2;
  909. case "Mar":
  910. return 3;
  911. case "Apr":
  912. return 4;
  913. case "May":
  914. return 5;
  915. case "Jun":
  916. return 6;
  917. case "Jul":
  918. return 7;
  919. case "Aug":
  920. return 8;
  921. case "Sep":
  922. return 9;
  923. case "Oct":
  924. return 10;
  925. case "Nov":
  926. return 11;
  927. case "Dec":
  928. return 12;
  929. default:
  930. throw new Zend_Date_Exception('Month ($name) is not a known month');
  931. }
  932. }
  933. /**
  934. * Counts the exact year number
  935. * < 70 - 2000 added, >70 < 100 - 1900, others just returned
  936. *
  937. * @param integer $value year number
  938. * @return integer Number of year
  939. */
  940. private function _century($value)
  941. {
  942. if ($value >= 0) {
  943. if ($value < 70) {
  944. $value += 2000;
  945. } else if ($value < 100) {
  946. $value += 1900;
  947. }
  948. }
  949. return $value;
  950. }
  951. /**
  952. * Sets the given date as new date or a given datepart as new datepart returning the new datepart
  953. * This could be for example a localized dayname, the date without time,
  954. * the month or only the seconds. There are about 50 different supported date parts.
  955. * For a complete list of supported datepart values look into the docu
  956. *
  957. * @param string|integer|array|Zend_Date $date Date or datepart to set
  958. * @param string $part OPTIONAL Part of the date to set, if null the timestamp is set
  959. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  960. * @return integer|string new datepart
  961. * @throws Zend_Date_Exception
  962. */
  963. public function set($date, $part = null, $locale = null)
  964. {
  965. $result = $this->_calculate('set', $date, $part, $locale);
  966. return $result;
  967. }
  968. /**
  969. * Adds a date or datepart to the existing date, by extracting $part from $date,
  970. * and modifying this object by adding that part. The $part is then extracted from
  971. * this object and returned as an integer or numeric string (for large values, or $part's
  972. * corresponding to pre-defined formatted date strings).
  973. * This could be for example a ISO 8601 date, the hour the monthname or only the minute.
  974. * There are about 50 different supported date parts.
  975. * For a complete list of supported datepart values look into the docu.
  976. *
  977. * @param string|integer|array|Zend_Date $date Date or datepart to add
  978. * @param string $part OPTIONAL Part of the date to add, if null the timestamp is added
  979. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  980. * @return integer|string new datepart
  981. * @throws Zend_Date_Exception
  982. */
  983. public function add($date, $part = null, $locale = null)
  984. {
  985. $this->_calculate('add', $date, $part, $locale);
  986. $result = $this->get($part, $locale);
  987. return $result;
  988. }
  989. /**
  990. * Subtracts a date from another date.
  991. * This could be for example a RFC2822 date, the time,
  992. * the year or only the timestamp. There are about 50 different supported date parts.
  993. * For a complete list of supported datepart values look into the docu
  994. * Be aware: Adding -2 Months is not equal to Subtracting 2 Months !!!
  995. *
  996. * @param string|integer|array|Zend_Date $date Date or datepart to subtract
  997. * @param string $part OPTIONAL Part of the date to sub, if null the timestamp is subtracted
  998. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  999. * @return integer|string new datepart
  1000. * @throws Zend_Date_Exception
  1001. */
  1002. public function sub($date, $part = null, $locale = null)
  1003. {
  1004. $this->_calculate('sub', $date, $part, $locale);
  1005. $result = $this->get($part, $locale);
  1006. return $result;
  1007. }
  1008. /**
  1009. * Compares a date or datepart with the existing one.
  1010. * Returns -1 if earlier, 0 if equal and 1 if later.
  1011. *
  1012. * @param string|integer|array|Zend_Date $date Date or datepart to compare with the date object
  1013. * @param string $part OPTIONAL Part of the date to compare, if null the timestamp is subtracted
  1014. * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
  1015. * @return integer 0 = equal, 1 = later, -1 = earlier
  1016. * @throws Zend_Date_Exception
  1017. */
  1018. public function compare($date, $part = null, $locale = null)
  1019. {
  1020. $compare = $this->_calculate('cmp', $date, $part, $locale);
  1021. if ($compare > 0) {
  1022. return 1;
  1023. } else if ($compare < 0) {
  1024. return -1;
  1025. }
  1026. return 0;
  1027. }
  1028. /**
  1029. * Returns a new instance of Zend_Date with the selected part copied.
  1030. * To make an exact copy, use PHP's clone keyword.
  1031. * For a complete list of supported date part values look into the docu.
  1032. * If a date part is copied, all other date parts are set to standard values.
  1033. * For example: If only YEAR is copied, the returned date object is equal to
  1034. * 01-01-YEAR 00:00:00 (01-01-1970 00:00:00 is equal to timestamp 0)
  1035. * If only HOUR is copied, the returned date object is equal to
  1036. * 01-01-1970 HOUR:00:00 (so $this contains a timestamp equal to a timestamp of 0 plus HOUR).
  1037. *
  1038. * @param string $part Part of the date to compare, if null the timestamp is subtracted
  1039. * @param string|Zend_Locale $locale OPTIONAL New object's locale. No adjustments to timezone are made.
  1040. * @return Zend_Date
  1041. */
  1042. public function copyPart($part, $locale = null)
  1043. {
  1044. $clone = clone $this; // copy all instance variables
  1045. $clone->setUnixTimestamp(0); // except the timestamp
  1046. if ($locale != null) {
  1047. $clone->setLocale($locale); // set an other locale if selected
  1048. }
  1049. $clone->set($this, $part);
  1050. return $clone;
  1051. }
  1052. /**
  1053. * Calculates the date or object
  1054. *
  1055. * @param string $calc Calculation to make
  1056. * @param string|integer $date Date for calculation
  1057. * @param string|integer $comp Second date for calculation
  1058. * @param boolean|integer $dst Use dst correction if option is set
  1059. * @return integer|string|Zend_Date new timestamp or Zend_Date depending on calculation
  1060. */
  1061. private function _assign($calc, $date, $comp = 0, $dst = false)
  1062. {
  1063. switch ($calc) {
  1064. case 'set' :
  1065. if (!empty($comp)) {
  1066. $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $comp));
  1067. }
  1068. $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
  1069. $value = $this->getUnixTimestamp();
  1070. break;
  1071. case 'add' :
  1072. $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$add, $this->getUnixTimestamp(), $date));
  1073. $value = $this->getUnixTimestamp();
  1074. break;
  1075. case 'sub' :
  1076. $this->setUnixTimestamp(call_user_func(Zend_Locale_Math::$sub, $this->getUnixTimestamp(), $date));
  1077. $value = $this->getUnixTimestamp();
  1078. break;
  1079. default :
  1080. // cmp - compare
  1081. return call_user_func(Zend_Locale_Math::$comp, $comp, $date);
  1082. break;
  1083. }
  1084. // dst-correction if 'fix_dst' = true and dst !== false but only for non UTC and non GMT
  1085. if ((self::$_Options['fix_dst'] === true) and ($dst !== false) and ($this->_dst === true)) {
  1086. $hour

Large files files are truncated, but you can click here to view the full file