diff options
-rw-r--r-- | generic/tclClock.c | 11 | ||||
-rw-r--r-- | generic/tclDate.h | 4 | ||||
-rw-r--r-- | library/clock.tcl | 5 |
3 files changed, 15 insertions, 5 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c index e156cf3..1c9f77e 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -2249,6 +2249,9 @@ ConvertUTCToLocal( return TCL_ERROR; } + /* signal we need to revalidate TZ epoch next time fields gets used. */ + fields->flags |= CLF_CTZ; + /* we cannot cache (ranges unknown yet) */ } else { Tcl_WideInt rangesVal[2]; @@ -2258,6 +2261,9 @@ ConvertUTCToLocal( return TCL_ERROR; } + /* converted using table (TZ isn't :localtime) */ + fields->flags &= ~CLF_CTZ; + /* Cache the last conversion */ if (ltzoc != NULL) { /* slot was found above */ /* timezoneObj and changeover are the same */ @@ -3491,7 +3497,10 @@ baseNow: /* check base fields already cached (by TZ, last-second cache) */ if ( dataPtr->lastBase.timezoneObj == opts->timezoneObj - && dataPtr->lastBase.date.seconds == baseVal) { + && dataPtr->lastBase.date.seconds == baseVal + && (!(dataPtr->lastBase.date.flags & CLF_CTZ) + || dataPtr->lastTZEpoch == TzsetIfNecessary()) + ) { memcpy(date, &dataPtr->lastBase.date, ClockCacheableDateFieldsSize); } else { /* extact fields from base */ diff --git a/generic/tclDate.h b/generic/tclDate.h index 6e82a3f..0fd0fef 100644 --- a/generic/tclDate.h +++ b/generic/tclDate.h @@ -150,6 +150,8 @@ typedef enum ClockMsgCtLiteral { typedef enum {BCE=1, CE=0} ERA_ENUM; +#define CLF_CTZ (1 << 4) + typedef struct TclDateFields { /* Cacheable fields: */ @@ -175,6 +177,8 @@ typedef struct TclDateFields { int secondOfMin; /* Seconds of minute (in-between time only calculation) */ int secondOfDay; /* Seconds of day (in-between time only calculation) */ + int flags; /* 0 or CLF_CTZ */ + /* Non cacheable fields: */ Tcl_Obj *tzName; /* Name (or corresponding DST-abbreviation) of the diff --git a/library/clock.tcl b/library/clock.tcl index 529a4f9..504ba0b 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -968,10 +968,7 @@ proc ::tcl::clock::SetupTimeZone { timezone {alias {}} } { "time zone \"$timezone\" not found" } variable MINWIDE - if { $timezone eq {:localtime} } { - # Nothing to do, we'll convert using the localtime function - - } elseif { + if { [regexp {^([-+])(\d\d)(?::?(\d\d)(?::?(\d\d))?)?} $timezone \ -> s hh mm ss] } then { |