diff options
author | Michael G. Schwern <schwern@pobox.com> | 2008-10-02 16:18:54 -0400 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2009-01-03 18:38:56 +0100 |
commit | 806a119aef40085e6ee4a5a8bbab77cca98c9d08 (patch) | |
tree | 8ed1365a73b59eff53d7a2e2e219d3be5b3f6180 /time64.h | |
parent | 7643e68fdb02e6f17d9f2a5801be920285971156 (diff) | |
download | perl-806a119aef40085e6ee4a5a8bbab77cca98c9d08.tar.gz |
Remove the AIX work around code. Instead it should just set it's LOCALTIME_MAX to 0x7fff573e.
Update from y2038.
Use the new TM64 struct so years can go out past y2**31
Defines a Year type to avoid converting years to ints.
Remove the TIMGM work around code, using timegm64() is fine and it
saves us from having to convert from TM to tm.
Make functions private with static rather than the _foo convention.
Even faster for distant dates.
Diffstat (limited to 'time64.h')
-rw-r--r-- | time64.h | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -1,3 +1,5 @@ +#include <time.h> + #ifndef LOCALTIME64_H # define LOCALTIME64_H @@ -29,7 +31,12 @@ USE_SYSTEM_LOCALTIME USE_SYSTEM_GMTIME Should we use the system functions if the time is inside their range? + + USE_TM64 + Should we use a 64 bit safe tm struct which can handle a + year range greater than 2 billion? */ + #define SYSTEM_LOCALTIME_MAX LOCALTIME_MAX #define SYSTEM_LOCALTIME_MIN LOCALTIME_MIN #define SYSTEM_GMTIME_MAX GMTIME_MAX @@ -39,15 +46,44 @@ #define USE_SYSTEM_LOCALTIME 1 #define USE_SYSTEM_GMTIME 1 +/* Let's get all the time */ +#define USE_TM64 + +#ifdef USE_TM64 +#define TM TM64 +#else +#define TM tm +#endif /* 64 bit types. Set as appropriate for your system. */ typedef Quad_t Time64_T; typedef Quad_t Int64; typedef Int64 Year; -struct tm *gmtime64_r (const Time64_T *, struct tm *); -struct tm *localtime64_r (const Time64_T *, struct tm *); -Time64_T timegm64 (struct tm *); +struct TM *gmtime64_r (const Time64_T *, struct TM *); +struct TM *localtime64_r (const Time64_T *, struct TM *); +Time64_T timegm64 (struct TM *); + +/* A copy of the tm struct but with a 64 bit year */ +struct TM64 { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + Year tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + +#ifdef HAS_TM_TM_GMTOFF + long tm_gmtoff; +#endif + +#ifdef HAS_TM_TM_ZONE + char *tm_zone; +#endif +}; /* Not everyone has gm/localtime_r() */ |