|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sfldate.h" struct tm *safe_gmtime (const time_t *time_secs)
Handles time_t values that exceed 2038. The standard C gmtime() 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; /* Nbr seconds in 20 years */
}
time_struct = gmtime ((const time_t *) &adjusted_time);
if (time_struct) /* gmtime may be unimplemented */
time_struct-> tm_year += adjust_years;
return (time_struct);
}
| | << | < | > | >> |
|