简体   繁体   中英

Zend_Date_DateObject - timestamp check and cast

Can someone explain why Zend_Date_DateObject checks the type of its timestamp property before returning it (and casting it to either int or string...

    protected function getTimestamp()
    {
        if ($this->_unixTimestamp === intval($this->_unixTimestamp)) {
            return (int) $this->_unixTimestamp;
        } else {
            return (string) $this->_unixTimestamp;
        }
    }

This seems quite odd but there must be some logic being this??

According to their svn log:

> svn log http://framework.zend.com/svn/framework -r 2773
------------------------------------------------------------------------
r2773 | gavin | 2007-01-15 19:22:51 +0200 (Mon, 15 Jan 2007) | 5 lines

* consistency updates
* bug fixes
* updates for DateObject unit tests to work with recent changes
  (10 Errors, 3 Failures yet to fix)

------------------------------------------------------------------------

Some test that exercise this (string/int) behavior were added. So I would say that this is just for their unit tests to comply.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM