1
0
mirror of https://github.com/deadw00d/AROS.git synced 2026-03-21 04:36:15 +00:00

Properly set tm_gmoff for local zones.

Note: tm_gmoff has positive values for zones east of Greenwich, while
AROS GMTOffset from locale.library has negative values for such zones.
This commit is contained in:
deadwood
2024-10-07 17:55:18 +02:00
parent 035562bda5
commit bf0984f4ba

View File

@ -1,13 +1,20 @@
/*
Copyright (C) 1995-2012, The AROS Development Team. All rights reserved.
Copyright (C) 1995-2024, The AROS Development Team. All rights reserved.
Convert a time into a string, reentrant.
*/
/* At the moment no daylight saving time information
* Implementation has to be changed when DST is implemented in AROS
*/
static int __dstflag = -1;
/*****************************************************************************
NAME */
#include <time.h>
#include <aros/debug.h>
struct tm * localtime_r (
@ -16,7 +23,10 @@
struct tm * tm)
/* FUNCTION
Splits the system time in seconds into a structure.
The localtime_r() function converts the calendar time tt (assumed to
be UTC) to broken-down time representation, expressed users local
timezone.
The members of the tm structure are:
tm_sec - The number of seconds after the minute, normally in
@ -71,8 +81,16 @@
******************************************************************************/
{
time_t ti = *tt;
int gmtoffset = __stdc_gmtoffset() * 60;
ti -= __stdc_gmtoffset() * 60;
ti -= gmtoffset;
return gmtime_r (&ti, tm);
struct tm *_ret = gmtime_r (&ti, tm);
if (_ret)
{
tm->tm_isdst = __dstflag;
tm->tm_gmtoff = -gmtoffset;
}
return _ret;
} /* localtime_r */