diff -c -r orig/tcl8.3.2/generic/tclClock.c t832/tcl8.3.2/generic/tclClock.c *** orig/tcl8.3.2/generic/tclClock.c Mon Aug 7 23:30:56 2000 --- t832/tcl8.3.2/generic/tclClock.c Wed Apr 11 23:45:34 2001 *************** *** 257,263 **** int useGMT; /* Boolean */ char *format; /* Format string */ { ! struct tm *timeDataPtr; Tcl_DString buffer, uniBuffer; int bufSize; char *p; --- 257,263 ---- int useGMT; /* Boolean */ char *format; /* Format string */ { ! struct tm timeData; Tcl_DString buffer, uniBuffer; int bufSize; char *p; *************** *** 313,319 **** #endif tclockVal = clockVal; ! timeDataPtr = TclpGetDate((TclpTime_t) &tclockVal, useGMT); /* * Make a guess at the upper limit on the substituted string size --- 313,319 ---- #endif tclockVal = clockVal; ! TclpGetDate((TclpTime_t) &tclockVal, useGMT,&timeData); /* * Make a guess at the upper limit on the substituted string size *************** *** 332,338 **** Tcl_MutexLock(&clockMutex); result = TclpStrftime(buffer.string, (unsigned int) bufSize, format, ! timeDataPtr); Tcl_MutexUnlock(&clockMutex); #ifndef HAVE_TM_ZONE --- 332,338 ---- Tcl_MutexLock(&clockMutex); result = TclpStrftime(buffer.string, (unsigned int) bufSize, format, ! &timeData); Tcl_MutexUnlock(&clockMutex); #ifndef HAVE_TM_ZONE diff -c -r orig/tcl8.3.2/generic/tclDate.c t832/tcl8.3.2/generic/tclDate.c *** orig/tcl8.3.2/generic/tclDate.c Mon Aug 7 23:30:36 2000 --- t832/tcl8.3.2/generic/tclDate.c Wed Apr 11 23:37:17 2001 *************** *** 452,457 **** --- 452,458 ---- time_t tod; time_t Julian; int i; + struct tm tms; /* Figure out how many days are in February for the given year. * Every year divisible by 4 is a leap year. *************** *** 489,496 **** Julian += tod; /* Perform a preliminary DST compensation ?? */ if (DSTmode == DSTon ! || (DSTmode == DSTmaybe && TclpGetDate((TclpTime_t)&Julian, 0)->tm_isdst)) Julian -= 60 * 60; *TimePtr = Julian; return 0; --- 490,500 ---- Julian += tod; /* Perform a preliminary DST compensation ?? */ + + TclpGetDate((TclpTime_t)&Julian,0,&tms); + if (DSTmode == DSTon ! || (DSTmode == DSTmaybe && tms.tm_isdst)) Julian -= 60 * 60; *TimePtr = Julian; return 0; *************** *** 504,511 **** { time_t StartDay; time_t FutureDay; ! StartDay = (TclpGetDate((TclpTime_t)&Start, 0)->tm_hour + 1) % 24; ! FutureDay = (TclpGetDate((TclpTime_t)&Future, 0)->tm_hour + 1) % 24; return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; } --- 508,519 ---- { time_t StartDay; time_t FutureDay; ! struct tm tms; ! ! TclpGetDate((TclpTime_t)&Start,0,&tms); ! StartDay = (tms.tm_hour + 1) % 24; ! TclpGetDate((TclpTime_t)&Future,0,&tms); ! FutureDay = (tms.tm_hour + 1) % 24; return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; } *************** *** 516,527 **** time_t DayOrdinal; time_t DayNumber; { ! struct tm *tm; time_t now; now = Start; ! tm = TclpGetDate((TclpTime_t)&now, 0); ! now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); return DSTcorrect(Start, now); } --- 524,535 ---- time_t DayOrdinal; time_t DayNumber; { ! struct tm tm; time_t now; now = Start; ! TclpGetDate((TclpTime_t)&now, 0,&tm); ! now += SECSPERDAY * ((DayNumber - tm.tm_wday + 7) % 7); now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); return DSTcorrect(Start, now); } *************** *** 532,554 **** time_t MonthOrdinal; time_t MonthNumber; { ! struct tm *tm; time_t now; int result; now = Start; ! tm = TclpGetDate((TclpTime_t)&now, 0); /* To compute the next n'th month, we use this alg: * add n to year value * if currentMonth < requestedMonth decrement year value by 1 (so that * doing next february from january gives us february of the current year) * set day to 1, time to 0 */ ! tm->tm_year += MonthOrdinal; ! if (tm->tm_mon < MonthNumber - 1) { ! tm->tm_year--; } ! result = Convert(MonthNumber, (time_t) 1, tm->tm_year + TM_YEAR_BASE, (time_t) 0, (time_t) 0, (time_t) 0, MER24, DSTmaybe, &now); if (result < 0) { return 0; --- 540,562 ---- time_t MonthOrdinal; time_t MonthNumber; { ! struct tm tm; time_t now; int result; now = Start; ! TclpGetDate((TclpTime_t)&now, 0, &tm); /* To compute the next n'th month, we use this alg: * add n to year value * if currentMonth < requestedMonth decrement year value by 1 (so that * doing next february from january gives us february of the current year) * set day to 1, time to 0 */ ! tm.tm_year += MonthOrdinal; ! if (tm.tm_mon < MonthNumber - 1) { ! tm.tm_year--; } ! result = Convert(MonthNumber, (time_t) 1, tm.tm_year + TM_YEAR_BASE, (time_t) 0, (time_t) 0, (time_t) 0, MER24, DSTmaybe, &now); if (result < 0) { return 0; *************** *** 562,568 **** time_t RelMonth; time_t *TimePtr; { ! struct tm *tm; time_t Month; time_t Year; time_t Julian; --- 570,576 ---- time_t RelMonth; time_t *TimePtr; { ! struct tm tm; time_t Month; time_t Year; time_t Julian; *************** *** 572,583 **** *TimePtr = 0; return 0; } ! tm = TclpGetDate((TclpTime_t)&Start, 0); ! Month = 12 * (tm->tm_year + TM_YEAR_BASE) + tm->tm_mon + RelMonth; Year = Month / 12; Month = Month % 12 + 1; ! result = Convert(Month, (time_t) tm->tm_mday, Year, ! (time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec, MER24, DSTmaybe, &Julian); /* * The following iteration takes into account the case were we jump --- 580,591 ---- *TimePtr = 0; return 0; } ! TclpGetDate((TclpTime_t)&Start, 0,&tm); ! Month = 12 * (tm.tm_year + TM_YEAR_BASE) + tm.tm_mon + RelMonth; Year = Month / 12; Month = Month % 12 + 1; ! result = Convert(Month, (time_t) tm.tm_mday, Year, ! (time_t) tm.tm_hour, (time_t) tm.tm_min, (time_t) tm.tm_sec, MER24, DSTmaybe, &Julian); /* * The following iteration takes into account the case were we jump *************** *** 587,596 **** * 28 (which always works unless the date is bad in another way). */ ! while ((result != 0) && (tm->tm_mday > 28)) { ! tm->tm_mday--; ! result = Convert(Month, (time_t) tm->tm_mday, Year, ! (time_t) tm->tm_hour, (time_t) tm->tm_min, (time_t) tm->tm_sec, MER24, DSTmaybe, &Julian); } if (result != 0) { --- 595,604 ---- * 28 (which always works unless the date is bad in another way). */ ! while ((result != 0) && (tm.tm_mday > 28)) { ! tm.tm_mday--; ! result = Convert(Month, (time_t) tm.tm_mday, Year, ! (time_t) tm.tm_hour, (time_t) tm.tm_min, (time_t) tm.tm_sec, MER24, DSTmaybe, &Julian); } if (result != 0) { *************** *** 819,825 **** long zone; unsigned long *timePtr; { ! struct tm *tm; time_t Start; time_t Time; time_t tod; --- 827,833 ---- long zone; unsigned long *timePtr; { ! struct tm tm; time_t Start; time_t Time; time_t tod; *************** *** 828,838 **** TclDateInput = p; /* now has to be cast to a time_t for 64bit compliance */ Start = now; ! tm = TclpGetDate((TclpTime_t) &Start, 0); ! thisyear = tm->tm_year + TM_YEAR_BASE; TclDateYear = thisyear; ! TclDateMonth = tm->tm_mon + 1; ! TclDateDay = tm->tm_mday; TclDateTimezone = zone; if (zone == -50000) { TclDateDSTmode = DSToff; /* assume GMT */ --- 836,846 ---- TclDateInput = p; /* now has to be cast to a time_t for 64bit compliance */ Start = now; ! TclpGetDate((TclpTime_t) &Start, 0, &tm); ! thisyear = tm.tm_year + TM_YEAR_BASE; TclDateYear = thisyear; ! TclDateMonth = tm.tm_mon + 1; ! TclDateDay = tm.tm_mday; TclDateTimezone = zone; if (zone == -50000) { TclDateDSTmode = DSToff; /* assume GMT */ *************** *** 889,896 **** } else { Start = now; if (!TclDateHaveRel) { ! Start -= ((tm->tm_hour * 60L * 60L) + ! tm->tm_min * 60L) + tm->tm_sec; } } --- 897,904 ---- } else { Start = now; if (!TclDateHaveRel) { ! Start -= ((tm.tm_hour * 60L * 60L) + ! tm.tm_min * 60L) + tm.tm_sec; } } diff -c -r orig/tcl8.3.2/generic/tclIntDecls.h t832/tcl8.3.2/generic/tclIntDecls.h *** orig/tcl8.3.2/generic/tclIntDecls.h Thu Jul 27 03:39:18 2000 --- t832/tcl8.3.2/generic/tclIntDecls.h Wed Apr 11 23:37:25 2001 *************** *** 450,456 **** /* 132 */ EXTERN int TclpHasSockets _ANSI_ARGS_((Tcl_Interp * interp)); /* 133 */ ! EXTERN struct tm * TclpGetDate _ANSI_ARGS_((TclpTime_t time, int useGMT)); /* 134 */ EXTERN size_t TclpStrftime _ANSI_ARGS_((char * s, size_t maxsize, CONST char * format, CONST struct tm * t)); --- 450,456 ---- /* 132 */ EXTERN int TclpHasSockets _ANSI_ARGS_((Tcl_Interp * interp)); /* 133 */ ! EXTERN struct tm * TclpGetDate _ANSI_ARGS_((TclpTime_t time, int useGMT, struct tm * t)); /* 134 */ EXTERN size_t TclpStrftime _ANSI_ARGS_((char * s, size_t maxsize, CONST char * format, CONST struct tm * t)); diff -c -r orig/tcl8.3.2/unix/tclUnixTime.c t832/tcl8.3.2/unix/tclUnixTime.c *** orig/tcl8.3.2/unix/tclUnixTime.c Fri Jan 14 23:15:52 2000 --- t832/tcl8.3.2/unix/tclUnixTime.c Wed Apr 11 23:37:31 2001 *************** *** 114,125 **** #if defined(HAVE_TM_TZADJ) # define TCL_GOT_TIMEZONE time_t curTime = (time_t) currentTime; ! struct tm *timeDataPtr = localtime(&curTime); int timeZone; ! timeZone = timeDataPtr->tm_tzadj / 60; ! if (timeDataPtr->tm_isdst) { timeZone += 60; } --- 114,126 ---- #if defined(HAVE_TM_TZADJ) # define TCL_GOT_TIMEZONE + struct tm timeData; time_t curTime = (time_t) currentTime; ! localtime_r(&curTime,&timeData); int timeZone; ! timeZone = timeData.tm_tzadj / 60; ! if (timeData.tm_isdst) { timeZone += 60; } *************** *** 129,139 **** #if defined(HAVE_TM_GMTOFF) && !defined (TCL_GOT_TIMEZONE) # define TCL_GOT_TIMEZONE time_t curTime = (time_t) currentTime; ! struct tm *timeDataPtr = localtime(&curTime); int timeZone; ! timeZone = -(timeDataPtr->tm_gmtoff / 60); ! if (timeDataPtr->tm_isdst) { timeZone += 60; } --- 130,141 ---- #if defined(HAVE_TM_GMTOFF) && !defined (TCL_GOT_TIMEZONE) # define TCL_GOT_TIMEZONE time_t curTime = (time_t) currentTime; ! struct tm timeData; int timeZone; ! localtime_r(&curTime,&timeData); ! timeZone = -(timeData.tm_gmtoff / 60); ! if (timeData.tm_isdst) { timeZone += 60; } *************** *** 150,160 **** int timeZone; time_t tt; ! struct tm *stm; tt = 849268800L; /* 1996-11-29 12:00:00 GMT */ ! stm = localtime(&tt); /* eg 1996-11-29 6:00:00 CST6CDT */ /* The calculation below assumes a max of +12 or -12 hours from GMT */ ! timeZone = (12 - stm->tm_hour)*60 + (0 - stm->tm_min); return timeZone; /* eg +360 for CST6CDT */ #endif --- 152,163 ---- int timeZone; time_t tt; ! struct tm stm; ! tt = 849268800L; /* 1996-11-29 12:00:00 GMT */ ! localtime_r(&tt,&stm); /* eg 1996-11-29 6:00:00 CST6CDT */ /* The calculation below assumes a max of +12 or -12 hours from GMT */ ! timeZone = (12 - stm.tm_hour)*60 + (0 - stm.tm_min); return timeZone; /* eg +360 for CST6CDT */ #endif *************** *** 260,277 **** *---------------------------------------------------------------------- */ ! struct tm * ! TclpGetDate(time, useGMT) TclpTime_t time; int useGMT; { CONST time_t *tp = (CONST time_t *)time; if (useGMT) { ! return gmtime(tp); } else { ! return localtime(tp); } } /* --- 263,282 ---- *---------------------------------------------------------------------- */ ! struct tm * ! TclpGetDate(time, useGMT,tmptr) TclpTime_t time; int useGMT; + struct tm *tmptr; { CONST time_t *tp = (CONST time_t *)time; if (useGMT) { ! gmtime_r(tp,tmptr); } else { ! localtime_r(tp,tmptr); } + return tmptr; } /*