|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sfldate.h" struct tm *safe_localtime (const time_t *time_secs)
Handles time_t values that exceed 2038. The standard C localtime() function fails on most systems when the date passes 2038.
{
qbyte
adjusted_time;
struct tm
*time_struct;
int
adjust_years = 0;
adjusted_time = (qbyte) *time_secs;
while (adjusted_time > LONG_MAX)
{
adjust_years += 20;
adjusted_time -= 631152000; /* Number of seconds in 20 years */
}
time_struct = localtime ((const time_t *) &adjusted_time);
ASSERT (time_struct); /* MUST be valid now... */
time_struct-> tm_year += adjust_years;
return (time_struct);
}
| | << | < | > | >> |
|