3434#include <ext/standard/info.h>
3535#include <Zend/zend_interfaces.h>
3636#include <ext/spl/spl_iterators.h>
37+ #include <ext/date/php_date.h>
3738/* Our Compatability header */
3839#include "phongo_compat.h"
3940
@@ -112,7 +113,10 @@ PHP_METHOD(UTCDateTime, __toString)
112113 Returns DateTime object representing this UTCDateTime */
113114PHP_METHOD (UTCDateTime , toDateTime )
114115{
115- php_phongo_utcdatetime_t * intern ;
116+ php_phongo_utcdatetime_t * intern ;
117+ php_date_obj * datetime_obj ;
118+ char * sec ;
119+ size_t sec_len ;
116120
117121
118122 intern = Z_UTCDATETIME_OBJ_P (getThis ());
@@ -121,7 +125,14 @@ PHP_METHOD(UTCDateTime, toDateTime)
121125 return ;
122126 }
123127
124- php_phongo_new_datetime_from_utcdatetime (return_value , intern -> milliseconds TSRMLS_CC );
128+ object_init_ex (return_value , php_date_get_date_ce ());
129+ datetime_obj = Z_PHPDATE_P (return_value );
130+
131+ sec_len = spprintf (& sec , 0 , "@%" PRId64 , intern -> milliseconds / 1000 );
132+ php_date_initialize (datetime_obj , sec , sec_len , NULL , NULL , 0 TSRMLS_CC );
133+ efree (sec );
134+
135+ datetime_obj -> time -> f = (double ) (intern -> milliseconds % 1000 ) / 1000 ;
125136}
126137/* }}} */
127138
0 commit comments