Author: Tim Düsterhus (TimWolla)
Committer: GitHub (web-flow)
Pusher: TimWolla
Date: 2025-05-12T10:53:51+02:00
Commit: https://github.com/php/php-src/commit/5e65d8e126ba2674f9e0713cf305f40c5a8a7805
Raw diff: https://github.com/php/php-src/commit/5e65d8e126ba2674f9e0713cf305f40c5a8a7805.diff
standard: Remove php_std_date()
C API (#18522)
This function is unused and trivially replaced by php_format_date()
(which is
already used to format date headers in the CLI server and ext/session). Remove
it to slim down the codebase, allowing to remove an entire header (and a source
file once the deprecated strptime()
userland function is removed).
Changed paths:
D ext/standard/datetime.h
M UPGRADING.INTERNALS
M ext/standard/datetime.c
M ext/standard/php_standard.h
Diff:
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 7c7f093e50cc..2ed9c2510521 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -64,6 +64,8 @@ PHP 8.5 INTERNALS UPGRADE NOTES
- ext/standard
. Added php_url_decode_ex() and php_raw_url_decode_ex() that unlike their
non-ex counterparts do not work in-place.
+ . The php_std_date() function has been removed. Use php_format_date() with
+ the "D, d M Y H:i:s \\G\\M\\T" format instead.
========================
4. OpCode changes
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
index 24569f8f6a39..93f47f0f858b 100644
--- a/ext/standard/datetime.c
+++ b/ext/standard/datetime.c
@@ -17,50 +17,12 @@
*/
#include "php.h"
-#include "zend_operators.h"
-#include "datetime.h"
#include "php_globals.h"
#include <time.h>
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
-#include <stdio.h>
-
-static const char * const mon_short_names[] = {
- "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec"
-};
-
-static const char * const day_short_names[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu",
"Fri", "Sat"
-};
-
-/* {{{ PHPAPI char *php_std_date(time_t t)
- Return date string in standard format for http headers */
-PHPAPI char *php_std_date(time_t t)
-{
- struct tm *tm1, tmbuf;
- char *str;
-
- tm1 = php_gmtime_r(&t, &tmbuf);
- str = emalloc(81);
- str[0] = '\0';
-
- if (!tm1) {
- return str;
- }
-
- snprintf(str, 80, "%s, %02d %s %04d %02d:%02d:%02d GMT",
- day_short_names[tm1->tm_wday],
- tm1->tm_mday,
- mon_short_names[tm1->tm_mon],
- tm1->tm_year + 1900,
- tm1->tm_hour, tm1->tm_min, tm1->tm_sec);
-
- str[79] = 0;
- return (str);
-}
-/* }}} */
#ifdef HAVE_STRPTIME
#ifndef HAVE_DECL_STRPTIME
diff --git a/ext/standard/datetime.h b/ext/standard/datetime.h
deleted file mode 100644
index da87cb8ece49..000000000000
--- a/ext/standard/datetime.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Copyright (c) The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | https://www.php.net/license/3_01.txt
|
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | [email protected] so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <[email protected]> |
- | Zeev Suraski <[email protected]> |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef DATETIME_H
-#define DATETIME_H
-
-PHPAPI char *php_std_date(time_t t);
-
-#endif /* DATETIME_H */
diff --git a/ext/standard/php_standard.h b/ext/standard/php_standard.h
index 5bf41431eeab..78eba25f11a5 100644
--- a/ext/standard/php_standard.h
+++ b/ext/standard/php_standard.h
@@ -30,7 +30,6 @@
#include "php_filestat.h"
#include "php_browscap.h"
#include "pack.h"
-#include "datetime.h"
#include "url.h"
#include "pageinfo.h"
#include "fsock.h"