summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-01-10 22:02:10 (GMT)
committersebres <sebres@users.sourceforge.net>2017-01-10 22:02:10 (GMT)
commitf70ebac8b8c9c01999150364b4155b0d50911cbc (patch)
tree7ee977c045032f7763000f522709ce2999cb2dad /generic/tclClock.c
parent980f0e3d6b56fbddec0b97988c695f912caa5082 (diff)
downloadtcl-f70ebac8b8c9c01999150364b4155b0d50911cbc.zip
tcl-f70ebac8b8c9c01999150364b4155b0d50911cbc.tar.gz
tcl-f70ebac8b8c9c01999150364b4155b0d50911cbc.tar.bz2
[temp-commit]: ClockFreeScan ready, test case passed (2 failure because of wrong :localtime zone by TZ-switch, to be fixed)
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 5710d6d..7256320 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -122,6 +122,7 @@ typedef struct ClockClientData {
Tcl_Obj *GMTSetupTZData;
Tcl_Obj *LastSetupTimeZone;
Tcl_Obj *LastSetupTZData;
+ Tcl_Obj *LastUsedSetupTimeZone;
} ClockClientData;
/*
@@ -324,6 +325,7 @@ TclClockInit(
data->GMTSetupTZData = NULL;
data->LastSetupTimeZone = NULL;
data->LastSetupTZData = NULL;
+ data->LastUsedSetupTimeZone = NULL;
/*
* Install the commands.
@@ -477,6 +479,7 @@ ClockConfigureObjCmd(
if (i+1 < objc) {
timezoneObj = NormTimezoneObj(dataPtr, objv[i+1]);
if (optionIndex == CLOCK_SETUP_TZ) {
+ dataPtr->LastUsedSetupTimeZone = timezoneObj;
if (timezoneObj == litPtr[LIT_GMT]) {
optionIndex = CLOCK_SETUP_GMT;
} else if (timezoneObj == dataPtr->LastSystemTimeZone) {
@@ -510,14 +513,15 @@ ClockConfigureObjCmd(
if (i+1 < objc) {
Tcl_IncrRefCount(
dataPtr->LastSetupTimeZone = timezoneObj);
- } else if (dataPtr->LastSetupTimeZone) {
- Tcl_SetObjResult(interp, dataPtr->LastSetupTimeZone);
+ } else if (dataPtr->LastUsedSetupTimeZone) {
+ Tcl_SetObjResult(interp, dataPtr->LastUsedSetupTimeZone);
}
}
}
}
if (optionIndex == CLOCK_CLEAR_CACHE) {
dataPtr->LastTZEpoch = 0;
+ dataPtr->LastUsedSetupTimeZone = NULL;
}
}
@@ -605,6 +609,11 @@ ClockSetupTimeZone(
Tcl_Obj **literals = dataPtr->literals;
Tcl_Obj *callargs[2];
+ /* if cached (if already setup this one) */
+ if (timezoneObj == dataPtr->LastUsedSetupTimeZone) {
+ return timezoneObj;
+ }
+
/* differentiate GMT and system zones, because used often and already set */
timezoneObj = NormTimezoneObj(dataPtr, timezoneObj);
if ( timezoneObj == dataPtr->GMTSetupTimeZone
@@ -2546,6 +2555,15 @@ ClockScanObjCmd(
}
*/
+ if (1) {
+ /* TODO: Tcled Scan proc - */
+ Tcl_Obj *callargs[10];
+ memcpy(callargs, objv, objc * sizeof(*objv));
+ callargs[0] = Tcl_NewStringObj("::tcl::clock::__org_scan", -1);
+ return Tcl_EvalObjv(interp, objc, callargs, 0);
+ }
+ // Tcl_SetObjResult(interp, Tcl_NewWideIntObj(10000000));
+
return TCL_OK;
}
@@ -2635,10 +2653,10 @@ ClockFreeScan(
if (yy.dateHaveDate) {
if (yy.dateYear < 100) {
- yy.dateYear += ClockCurrentYearCentury(clientData, interp);
- if (yy.dateYear > ClockGetYearOfCenturySwitch(clientData, interp)) {
+ if (yy.dateYear >= ClockGetYearOfCenturySwitch(clientData, interp)) {
yy.dateYear -= 100;
}
+ yy.dateYear += ClockCurrentYearCentury(clientData, interp);
}
date.era = CE;
date.year = yy.dateYear;