summaryrefslogtreecommitdiffstats
path: root/server/util_time.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-25 04:41:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-25 04:41:26 +0000
commit7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b (patch)
treefdeb0b5ff80273f95ce61607fc3613dff0b9a235 /server/util_time.c
parentAdding upstream version 2.4.38. (diff)
downloadapache2-7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b.tar.xz
apache2-7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b.zip
Adding upstream version 2.4.59.upstream/2.4.59upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'server/util_time.c')
-rw-r--r--server/util_time.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/server/util_time.c b/server/util_time.c
index 3632d0d..299b53c 100644
--- a/server/util_time.c
+++ b/server/util_time.c
@@ -22,9 +22,11 @@
* */
#define AP_CTIME_USEC_LENGTH 7
-/* Length of ISO 8601 date/time */
+/* Length of ISO 8601 date/time (including trailing '\0') */
#define AP_CTIME_COMPACT_LEN 20
+/* Length of timezone offset from GMT ([+-]hhmm) plus leading space */
+#define AP_CTIME_GMTOFF_LEN 6
/* Cache for exploded values of recent timestamps
*/
@@ -181,7 +183,13 @@ AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t,
needed += AP_CTIME_USEC_LENGTH;
}
- /* Check the provided buffer length */
+ if (option & AP_CTIME_OPTION_GMTOFF) {
+ needed += AP_CTIME_GMTOFF_LEN;
+ }
+
+ /* Check the provided buffer length (note: above AP_CTIME_COMPACT_LEN
+ * and APR_CTIME_LEN include the trailing '\0'; so does 'needed' then).
+ */
if (len && *len >= needed) {
*len = needed;
}
@@ -193,9 +201,10 @@ AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t,
}
/* example without options: "Wed Jun 30 21:49:08 1993" */
- /* 123456789012345678901234 */
/* example for compact format: "1993-06-30 21:49:08" */
- /* 1234567890123456789 */
+ /* example for compact+usec+gmtoff format:
+ * "1993-06-30 22:49:08.123456 +0100"
+ */
ap_explode_recent_localtime(&xt, t);
real_year = 1900 + xt.tm_year;
@@ -249,7 +258,23 @@ AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t,
*date_str++ = real_year % 100 / 10 + '0';
*date_str++ = real_year % 10 + '0';
}
- *date_str++ = 0;
+ if (option & AP_CTIME_OPTION_GMTOFF) {
+ int off = xt.tm_gmtoff, off_hh, off_mm;
+ char sign = '+';
+ if (off < 0) {
+ off = -off;
+ sign = '-';
+ }
+ off_hh = off / 3600;
+ off_mm = off % 3600 / 60;
+ *date_str++ = ' ';
+ *date_str++ = sign;
+ *date_str++ = off_hh / 10 + '0';
+ *date_str++ = off_hh % 10 + '0';
+ *date_str++ = off_mm / 10 + '0';
+ *date_str++ = off_mm % 10 + '0';
+ }
+ *date_str = 0;
return APR_SUCCESS;
}