| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

safe_gmtime

#include "sfldate.h"
struct tm
*safe_gmtime (const time_t *time_secs)

Synopsis

Handles time_t values that exceed 2038. The standard C gmtime() function fails on most systems when the date passes 2038.

Source Code - (sfldate.c)

{
    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);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation