@@ -49,6 +49,11 @@ static inline long long php_date_llabs( long long i ) { return i >= 0 ? i : -i;
4949#define DATE_A64I (i , s ) i = strtoll(s, NULL, 10)
5050#endif
5151
52+ ZEND_ATTRIBUTE_DEPRECATED
53+ PHPAPI time_t php_time (void ) {
54+ return zend_time_real_get ();
55+ }
56+
5257/*
5358 * RFC822, Section 5.1: http://www.ietf.org/rfc/rfc822.txt
5459 * date-time = [ day "," ] date time ; dd mm yy hh:mm:ss zzz
@@ -847,7 +852,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, bool localtime)
847852 ZEND_PARSE_PARAMETERS_END ();
848853
849854 if (ts_is_null ) {
850- ts = zend_realtime_get ();
855+ ts = zend_time_real_get ();
851856 }
852857
853858 RETURN_STR (php_format_date (ZSTR_VAL (format ), ZSTR_LEN (format ), ts , localtime ));
@@ -1011,7 +1016,7 @@ PHP_FUNCTION(idate)
10111016 }
10121017
10131018 if (ts_is_null ) {
1014- ts = zend_realtime_get ();
1019+ ts = zend_time_real_get ();
10151020 }
10161021
10171022 ret = php_idate (ZSTR_VAL (format )[0 ], ts , 0 );
@@ -1091,7 +1096,7 @@ PHP_FUNCTION(strtotime)
10911096 now -> tz_info = tzi ;
10921097 now -> zone_type = TIMELIB_ZONETYPE_ID ;
10931098 timelib_unixtime2local (now ,
1094- !preset_ts_is_null ? (timelib_sll ) preset_ts : (timelib_sll ) zend_realtime_get ());
1099+ !preset_ts_is_null ? (timelib_sll ) preset_ts : (timelib_sll ) zend_time_real_get ());
10951100
10961101 t = timelib_strtotime (ZSTR_VAL (times ), ZSTR_LEN (times ), & error ,
10971102 DATE_TIMEZONEDB , php_date_parse_tzfile_wrapper );
@@ -1142,15 +1147,15 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, bool gmt)
11421147 /* Initialize structure with current time */
11431148 now = timelib_time_ctor ();
11441149 if (gmt ) {
1145- timelib_unixtime2gmt (now , (timelib_sll ) zend_realtime_get ());
1150+ timelib_unixtime2gmt (now , (timelib_sll ) zend_time_real_get ());
11461151 } else {
11471152 tzi = get_timezone_info ();
11481153 if (!tzi ) {
11491154 return ;
11501155 }
11511156 now -> tz_info = tzi ;
11521157 now -> zone_type = TIMELIB_ZONETYPE_ID ;
1153- timelib_unixtime2local (now , (timelib_sll ) zend_realtime_get ());
1158+ timelib_unixtime2local (now , (timelib_sll ) zend_time_real_get ());
11541159 }
11551160
11561161 now -> h = hou ;
@@ -1260,7 +1265,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gmt)
12601265 }
12611266
12621267 if (timestamp_is_null ) {
1263- timestamp = (zend_long ) zend_realtime_get ();
1268+ timestamp = (zend_long ) zend_time_real_get ();
12641269 }
12651270
12661271 ts = timelib_time_ctor ();
@@ -1356,7 +1361,7 @@ PHP_FUNCTION(time)
13561361{
13571362 ZEND_PARSE_PARAMETERS_NONE ();
13581363
1359- RETURN_LONG ((zend_long ) zend_realtime_get ());
1364+ RETURN_LONG ((zend_long ) zend_time_real_get ());
13601365}
13611366/* }}} */
13621367
@@ -1376,7 +1381,7 @@ PHP_FUNCTION(localtime)
13761381 ZEND_PARSE_PARAMETERS_END ();
13771382
13781383 if (timestamp_is_null ) {
1379- timestamp = (zend_long ) zend_realtime_get ();
1384+ timestamp = (zend_long ) zend_time_real_get ();
13801385 }
13811386
13821387 tzi = get_timezone_info ();
@@ -1431,7 +1436,7 @@ PHP_FUNCTION(getdate)
14311436 ZEND_PARSE_PARAMETERS_END ();
14321437
14331438 if (timestamp_is_null ) {
1434- timestamp = (zend_long ) zend_realtime_get ();
1439+ timestamp = (zend_long ) zend_time_real_get ();
14351440 }
14361441
14371442 tzi = get_timezone_info ();
@@ -2331,15 +2336,6 @@ static void php_date_set_time_fraction(timelib_time *time, int microsecond)
23312336 time -> us = microsecond ;
23322337}
23332338
2334- static void php_date_get_current_time_with_fraction (time_t * sec , suseconds_t * usec )
2335- {
2336- struct timespec ts ;
2337-
2338- zend_realtime_spec (& ts );
2339- * sec = ts .tv_sec ;
2340- * usec = ts .tv_nsec / 1000 ;
2341- }
2342-
23432339PHPAPI bool php_date_initialize (php_date_obj * dateobj , const char * time_str , size_t time_str_len , const char * format , zval * timezone_object , int flags ) /* {{{ */
23442340{
23452341 timelib_time * now ;
@@ -2348,8 +2344,7 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
23482344 int type = TIMELIB_ZONETYPE_ID , new_dst = 0 ;
23492345 char * new_abbr = NULL ;
23502346 timelib_sll new_offset = 0 ;
2351- time_t sec ;
2352- suseconds_t usec ;
2347+ struct timespec ts ;
23532348 int options = 0 ;
23542349
23552350 if (dateobj -> time ) {
@@ -2428,9 +2423,9 @@ PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, siz
24282423 now -> tz_abbr = new_abbr ;
24292424 break ;
24302425 }
2431- php_date_get_current_time_with_fraction ( & sec , & usec );
2432- timelib_unixtime2local (now , (timelib_sll ) sec );
2433- php_date_set_time_fraction (now , usec );
2426+ zend_time_real_spec ( & ts );
2427+ timelib_unixtime2local (now , (timelib_sll ) ts . tv_sec );
2428+ php_date_set_time_fraction (now , ts . tv_nsec / 1000 );
24342429
24352430 if (!format
24362431 && time_str_len == sizeof ("now" ) - 1
0 commit comments