summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2008-10-02 16:18:54 -0400
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-01-03 18:38:56 +0100
commit806a119aef40085e6ee4a5a8bbab77cca98c9d08 (patch)
tree8ed1365a73b59eff53d7a2e2e219d3be5b3f6180 /pp_sys.c
parent7643e68fdb02e6f17d9f2a5801be920285971156 (diff)
downloadperl-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 'pp_sys.c')
-rw-r--r--pp_sys.c55
1 files changed, 3 insertions, 52 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 788aa7b680..74958ac43f 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -201,15 +201,6 @@ void endservent(void);
#undef PERL_EFF_ACCESS /* EFFective uid/gid ACCESS */
-/* AIX 5.2 and below use mktime for localtime, and defines the edge case
- * for time 0x7fffffff to be valid only in UTC. AIX 5.3 provides localtime64
- * available in the 32bit environment, which could warrant Configure
- * checks in the future.
- */
-#ifdef _AIX
-#define LOCALTIME_EDGECASE_BROKEN
-#endif
-
/* F_OK unused: if stat() cannot find it... */
#if !defined(PERL_EFF_ACCESS) && defined(HAS_ACCESS) && defined(EFF_ONLY_OK) && !defined(NO_EFF_ONLY_OK)
@@ -4404,53 +4395,13 @@ PP(pp_tms)
#endif /* HAS_TIMES */
}
-#ifdef LOCALTIME_EDGECASE_BROKEN
-static struct tm *S_my_localtime (pTHX_ Time_t *tp)
-{
- auto time_t T;
- auto struct tm *P;
-
- /* No workarounds in the valid range */
- if (!tp || *tp < 0x7fff573f || *tp >= 0x80000000)
- return (localtime (tp));
-
- /* This edge case is to workaround the undefined behaviour, where the
- * TIMEZONE makes the time go beyond the defined range.
- * gmtime (0x7fffffff) => 2038-01-19 03:14:07
- * If there is a negative offset in TZ, like MET-1METDST, some broken
- * implementations of localtime () (like AIX 5.2) barf with bogus
- * return values:
- * 0x7fffffff gmtime 2038-01-19 03:14:07
- * 0x7fffffff localtime 1901-12-13 21:45:51
- * 0x7fffffff mylocaltime 2038-01-19 04:14:07
- * 0x3c19137f gmtime 2001-12-13 20:45:51
- * 0x3c19137f localtime 2001-12-13 21:45:51
- * 0x3c19137f mylocaltime 2001-12-13 21:45:51
- * Given that legal timezones are typically between GMT-12 and GMT+12
- * we turn back the clock 23 hours before calling the localtime
- * function, and add those to the return value. This will never cause
- * day wrapping problems, since the edge case is Tue Jan *19*
- */
- T = *tp - 82800; /* 23 hour. allows up to GMT-23 */
- P = localtime (&T);
- P->tm_hour += 23;
- if (P->tm_hour >= 24) {
- P->tm_hour -= 24;
- P->tm_mday++; /* 18 -> 19 */
- P->tm_wday++; /* Mon -> Tue */
- P->tm_yday++; /* 18 -> 19 */
- }
- return (P);
-} /* S_my_localtime */
-#endif
-
PP(pp_gmtime)
{
dVAR;
dSP;
Time64_T when;
- struct tm tmbuf;
- struct tm *err;
+ struct TM tmbuf;
+ struct TM *err;
static const char * const dayname[] =
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
static const char * const monname[] =
@@ -4483,7 +4434,7 @@ PP(pp_gmtime)
if (err == NULL)
RETPUSHUNDEF;
- tsv = Perl_newSVpvf(aTHX_ "%s %s %2d %02d:%02d:%02d %d",
+ tsv = Perl_newSVpvf(aTHX_ "%s %s %2d %02d:%02d:%02d %lld",
dayname[tmbuf.tm_wday],
monname[tmbuf.tm_mon],
tmbuf.tm_mday,