summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <github@derickrethans.nl>2017-02-11 11:10:17 +0000
committerDerick Rethans <github@derickrethans.nl>2017-02-11 11:10:17 +0000
commiteb1f4e0210162cdd326c1ca7c55d2fa395003146 (patch)
tree872d2ff066d1a864d91087a69291682a51ab4408
parentcad92c124308f0026c49f6ad7d45b023d725c6fe (diff)
parent5113909259f897c9c69f23cf5f8f7ab8972d5eba (diff)
downloadphp-git-eb1f4e0210162cdd326c1ca7c55d2fa395003146.tar.gz
Merge branch 'PHP-7.1'
-rw-r--r--ext/date/php_date.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 4b78f060eb..a9a02ebc68 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2567,15 +2567,17 @@ static void php_date_set_time_fraction(timelib_time *time, int microseconds)
time->f = microseconds / 1000000;
}
-static void php_date_set_current_time_fraction(timelib_time *time)
+static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *usec)
{
#if HAVE_GETTIMEOFDAY
struct timeval tp = {0}; /* For setting microseconds */
gettimeofday(&tp, NULL);
- timelib_set_fraction_from_timeval(time, tp);
+ *sec = tp.tv_sec;
+ *usec = tp.tv_usec;
#else
- time->f = 0;
+ *sec = time(NULL);
+ *usec = 0;
#endif
}
@@ -2587,6 +2589,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
int type = TIMELIB_ZONETYPE_ID, new_dst = 0;
char *new_abbr = NULL;
timelib_sll new_offset = 0;
+ time_t sec;
+ suseconds_t usec;
if (dateobj->time) {
timelib_time_dtor(dateobj->time);
@@ -2651,8 +2655,9 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
now->tz_abbr = new_abbr;
break;
}
- timelib_unixtime2local(now, (timelib_sll) time(NULL));
- php_date_set_current_time_fraction(now);
+ php_date_get_current_time_with_fraction(&sec, &usec);
+ timelib_unixtime2local(now, (timelib_sll) sec);
+ php_date_set_time_fraction(now, usec);
timelib_fill_holes(dateobj->time, now, TIMELIB_NO_CLONE);
timelib_update_ts(dateobj->time, tzi);
timelib_update_from_sse(dateobj->time);