1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- mktime() is supposed to convert the time specification, given as local

time, into the number of seconds since January 1st, 1970, relative to
  UTC. This didn't really work up until now since the time value returned
  was given as local time.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14810 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-01-25 11:21:00 +00:00
parent d1aaa84bcc
commit 003faf7a24
4 changed files with 22 additions and 7 deletions

View File

@ -7,7 +7,12 @@
function. function.
- The fall-back function for converting time into a string in strftime() - The fall-back function for converting time into a string in strftime()
now calls itself for the "%x" and "%X" format specifiers. now calls itself for the "%c", "%x" and "%X" format specifiers.
- mktime() is supposed to convert the time specification, given as local
time, into the number of seconds since January 1st, 1970, relative to
UTC. This didn't really work up until now since the time value returned
was given as local time.
c.lib 1.186 (14.1.2005) c.lib 1.186 (14.1.2005)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: time_localtime_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ * $Id: time_localtime_r.c,v 1.3 2005-01-25 11:21:00 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -67,8 +67,8 @@ localtime_r(const time_t *t,struct tm * tm_ptr)
} }
#endif /* CHECK_FOR_NULL_POINTERS */ #endif /* CHECK_FOR_NULL_POINTERS */
/* The time parameter given represents local time and /* The time parameter given represents UTC and
* must be converted to UTC before we proceed. * must be converted to local time before we proceed.
*/ */
if(__default_locale != NULL) if(__default_locale != NULL)
gmt_offset = 60 * __default_locale->loc_GMTOffset; gmt_offset = 60 * __default_locale->loc_GMTOffset;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: time_mktime.c,v 1.3 2005-01-24 10:25:46 obarthel Exp $ * $Id: time_mktime.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -41,6 +41,10 @@
#include "time_headers.h" #include "time_headers.h"
#endif /* _TIME_HEADERS_H */ #endif /* _TIME_HEADERS_H */
#ifndef _LOCALE_HEADERS_H
#include "locale_headers.h"
#endif /* _LOCALE_HEADERS_H */
/****************************************************************************/ /****************************************************************************/
time_t time_t
@ -185,6 +189,11 @@ mktime(struct tm *tm)
tm->tm_yday = (seconds - delta) / (24 * 60 * 60); tm->tm_yday = (seconds - delta) / (24 * 60 * 60);
/* The data in 'struct tm *tm' was given in local time. We need
to convert the result into UTC. */
if(__default_locale != NULL)
seconds += 60 * __default_locale->loc_GMTOffset;
/* Finally, adjust for the difference between the Unix and the /* Finally, adjust for the difference between the Unix and the
AmigaOS epochs, which differ by 8 years. */ AmigaOS epochs, which differ by 8 years. */
result = seconds + UNIX_TIME_OFFSET; result = seconds + UNIX_TIME_OFFSET;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: time_time.c,v 1.3 2005-01-24 10:25:46 obarthel Exp $ * $Id: time_time.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $
* *
* :ts=4 * :ts=4
* *
@ -52,7 +52,8 @@ time(time_t * tptr)
PROFILE_ON(); PROFILE_ON();
/* This converts the DateStamp contents into the number of /* This converts the DateStamp contents into the number of
seconds elapsed since January 1st 1970. */ seconds elapsed since January 1st 1970. The time is
given as relative to UTC, not local time. */
result = __convert_datestamp_to_time(&ds); result = __convert_datestamp_to_time(&ds);
if(tptr != NULL) if(tptr != NULL)