diff options
author | sebres <sebres@users.sourceforge.net> | 2017-01-10 21:58:33 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-01-10 21:58:33 (GMT) |
commit | 58f947e48be58a2371a0d24f957244796306d2ba (patch) | |
tree | 3d33434ea4d17840e060eb16d05f43717ce157a0 /library | |
parent | 4cc1178952c2e7eef686282007f5046adceb1ec1 (diff) | |
download | tcl-58f947e48be58a2371a0d24f957244796306d2ba.zip tcl-58f947e48be58a2371a0d24f957244796306d2ba.tar.gz tcl-58f947e48be58a2371a0d24f957244796306d2ba.tar.bz2 |
[temp-commit]: clock scan with several optimization porting, still not-ready
Diffstat (limited to 'library')
-rwxr-xr-x | library/clock.tcl | 19 | ||||
-rw-r--r-- | library/init.tcl | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/library/clock.tcl b/library/clock.tcl index 5b48eb3..9c3f95c 100755 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -287,6 +287,10 @@ proc ::tcl::clock::Initialize {} { variable FEB_28 58 + # Current year century and year of century switch + variable CurrentYearCentury 2000 + variable YearOfCenturySwitch 37 + # Translation table to map Windows TZI onto cities, so that the Olson # rules can apply. In some cases the mapping is ambiguous, so it's wise # to specify $::env(TCL_TZ) rather than simply depending on the system @@ -1295,7 +1299,7 @@ proc ::tcl::clock::__org_scan { args } { # #---------------------------------------------------------------------- -proc ::tcl::clock::FreeScan { string base timezone locale } { +proc ::tcl::clock::__org_FreeScan { string base timezone locale } { variable TZData @@ -1341,7 +1345,8 @@ proc ::tcl::clock::FreeScan { string base timezone locale } { if { [llength $parseDate] > 0 } { lassign $parseDate y m d if { $y < 100 } { - if { $y >= 39 } { + variable YearOfCenturySwitch + if { $y > $YearOfCenturySwitch } { incr y 1900 } else { incr y 2000 @@ -2719,12 +2724,14 @@ proc ::tcl::clock::ScanWide { str } { proc ::tcl::clock::InterpretTwoDigitYear { date baseTime { twoDigitField yearOfCentury } { fourDigitField year } } { + variable CurrentYearCentury + variable YearOfCenturySwitch set yr [dict get $date $twoDigitField] - if { $yr <= 37 } { - dict set date $fourDigitField [expr { $yr + 2000 }] - } else { - dict set date $fourDigitField [expr { $yr + 1900 }] + incr yr $CurrentYearCentury + if { $yr <= $YearOfCenturySwitch } { + incr yr -100 } + dict set date $fourDigitField $yr return $date } diff --git a/library/init.tcl b/library/init.tcl index e6df12b..4bbce51 100644 --- a/library/init.tcl +++ b/library/init.tcl @@ -178,7 +178,7 @@ if {[interp issafe]} { # Auto-loading stubs for 'clock.tcl' - foreach cmd {add format FreeScan} { + foreach cmd {add format} { proc ::tcl::clock::$cmd args { variable TclLibDir source -encoding utf-8 [file join $TclLibDir clock.tcl] |