Skip to content

Commit 138ba06

Browse files
committed
Merge branch 'v1.2'
2 parents 0a7d1ba + cbb5f9f commit 138ba06

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/BSON/UTCDateTime.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ static bool php_phongo_utcdatetime_init_from_date(php_phongo_utcdatetime_t *inte
128128

129129
/* The following assignments use the same logic as date_format() in php_date.c */
130130
sec = datetime_obj->time->sse;
131+
#if PHP_VERSION_ID >= 70200
132+
usec = (int64_t) floor(datetime_obj->time->us);
133+
#else
131134
usec = (int64_t) floor(datetime_obj->time->f * 1000000 + 0.5);
135+
#endif
132136

133137
intern->milliseconds = (sec * 1000) + (usec / 1000);
134138
intern->initialized = true;
@@ -256,8 +260,13 @@ static PHP_METHOD(UTCDateTime, toDateTime)
256260
php_date_initialize(datetime_obj, sec, sec_len, NULL, NULL, 0 TSRMLS_CC);
257261
efree(sec);
258262

263+
#if PHP_VERSION_ID >= 70200
264+
datetime_obj->time->us = (intern->milliseconds % 1000) * 1000;
265+
#else
259266
datetime_obj->time->f = (double) (intern->milliseconds % 1000) / 1000;
260-
} /* }}} */
267+
#endif
268+
}
269+
/* }}} */
261270

262271
/* {{{ proto array MongoDB\BSON\UTCDateTime::jsonSerialize()
263272
*/

0 commit comments

Comments
 (0)