mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed bug #73837 ("new DateTime()" sometimes returns 1 second ago value).
This commit is contained in:
parent
808a11041d
commit
5113909259
2 changed files with 14 additions and 5 deletions
4
NEWS
4
NEWS
|
@ -13,6 +13,10 @@ PHP NEWS
|
||||||
. Fixed bug #61471 (Incomplete POST does not timeout but is passed to PHP).
|
. Fixed bug #61471 (Incomplete POST does not timeout but is passed to PHP).
|
||||||
(Zheng Shao)
|
(Zheng Shao)
|
||||||
|
|
||||||
|
- Date:
|
||||||
|
. Fixed bug #73837 ("new DateTime()" sometimes returns 1 second ago value).
|
||||||
|
(Derick)
|
||||||
|
|
||||||
- GD:
|
- GD:
|
||||||
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
|
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
|
||||||
parameters). (finwe)
|
parameters). (finwe)
|
||||||
|
|
|
@ -2549,15 +2549,17 @@ static void php_date_set_time_fraction(timelib_time *time, int microseconds)
|
||||||
time->f = microseconds / 1000000;
|
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
|
#if HAVE_GETTIMEOFDAY
|
||||||
struct timeval tp = {0}; /* For setting microseconds */
|
struct timeval tp = {0}; /* For setting microseconds */
|
||||||
|
|
||||||
gettimeofday(&tp, NULL);
|
gettimeofday(&tp, NULL);
|
||||||
timelib_set_fraction_from_timeval(time, tp);
|
*sec = tp.tv_sec;
|
||||||
|
*usec = tp.tv_usec;
|
||||||
#else
|
#else
|
||||||
time->f = 0;
|
*sec = time(NULL);
|
||||||
|
*usec = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2569,6 +2571,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
|
||||||
int type = TIMELIB_ZONETYPE_ID, new_dst = 0;
|
int type = TIMELIB_ZONETYPE_ID, new_dst = 0;
|
||||||
char *new_abbr = NULL;
|
char *new_abbr = NULL;
|
||||||
timelib_sll new_offset = 0;
|
timelib_sll new_offset = 0;
|
||||||
|
time_t sec;
|
||||||
|
suseconds_t usec;
|
||||||
|
|
||||||
if (dateobj->time) {
|
if (dateobj->time) {
|
||||||
timelib_time_dtor(dateobj->time);
|
timelib_time_dtor(dateobj->time);
|
||||||
|
@ -2633,8 +2637,9 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
|
||||||
now->tz_abbr = new_abbr;
|
now->tz_abbr = new_abbr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
timelib_unixtime2local(now, (timelib_sll) time(NULL));
|
php_date_get_current_time_with_fraction(&sec, &usec);
|
||||||
php_date_set_current_time_fraction(now);
|
timelib_unixtime2local(now, (timelib_sll) sec);
|
||||||
|
php_date_set_time_fraction(now, usec);
|
||||||
timelib_fill_holes(dateobj->time, now, TIMELIB_NO_CLONE);
|
timelib_fill_holes(dateobj->time, now, TIMELIB_NO_CLONE);
|
||||||
timelib_update_ts(dateobj->time, tzi);
|
timelib_update_ts(dateobj->time, tzi);
|
||||||
timelib_update_from_sse(dateobj->time);
|
timelib_update_from_sse(dateobj->time);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue