You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/29 14:26:56 UTC

(axis-axis2-c-core) 02/04: Fix local to UTC time conversion producing wrong year/month (AXIS2C-1527)

This is an automated email from the ASF dual-hosted git repository.

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git

commit 84e60425f3c036f51ad62760fd3f8f6f70595086
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Thu Jan 29 03:56:08 2026 -1000

    Fix local to UTC time conversion producing wrong year/month (AXIS2C-1527)
    
    The axutil_date_time_local_to_utc function was reading year and month
    values that were already in tm format (years since 1900, 0-indexed months)
    but treating them as actual calendar values. Then at the end, it converted
    them to tm format again, causing double-conversion.
    
    For example, input "2010-01-01T00:00:00+02:00" would:
    - Be stored as year=110, mon=0 (tm format)
    - Read as year=110, mon=0 (treated as actual values)
    - Output year=110-1900=-1790 (garbage)
    
    The fix converts from tm format to actual values at the start of the
    function, so calculations use real year/month values. The existing
    conversion at the end correctly converts back to tm format.
    
    Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
 util/src/date_time.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/util/src/date_time.c b/util/src/date_time.c
index f9bdadff2..ef3f19c35 100644
--- a/util/src/date_time.c
+++ b/util/src/date_time.c
@@ -789,8 +789,10 @@ axutil_date_time_local_to_utc(
 
     axutil_date_time_t *ret = NULL;
 
-    year = date_time->year;
-    mon = date_time->mon;
+    /* Convert from tm format (years since 1900, 0-indexed months) to actual values
+     * for calculations. The result is converted back to tm format at the end. */
+    year = date_time->year + 1900;
+    mon = date_time->mon + 1;
     day = date_time->day;
     hour = date_time->hour;
     min = date_time->min;