2020-03-04
| ||
17:13 | • Closed ticket [5116bce4bc]: clock: the distance between "2004-03-28 01:00:00" and "2004-03-28 03:00:00" is only ONE hour plus 6 other changes artifact: 9282e26440 user: sebres | |
2018-05-29
| ||
18:21 | • Pending ticket [ddc948cff9]: Tcl-clock speed-up / flightaware Tcl-bounties#4 plus 4 other changes artifact: 5bf5a9c2f1 user: sebres | |
2017-12-28
| ||
17:52 | • Ticket [3475995fff] solved/opt clock scan success by logical invalid date/time status still Open with 7 other changes artifact: d9e89b442f user: sebres | |
2012-02-15
| ||
17:47 | • Ticket [3475995fff]: 4 changes artifact: ac89e39c99 user: sebres | |
00:09 | • Ticket [3475995fff]: 4 changes artifact: b4630b63d0 user: sebres | |
2012-02-02
| ||
16:26 | • Ticket [3475995fff]: 4 changes artifact: 1361101951 user: sebres | |
16:26 | • Add attachment clock.tcl to ticket [3475995fff] artifact: 8ca7a5e2c8 user: sebres | |
16:25 | • Add attachment clock.tcl.patch to ticket [3475995fff] artifact: 29b8ec6aab user: sebres | |
16:25 | • Ticket [3475995fff] solved/opt clock scan success by logical invalid date/time status still Open with 4 other changes artifact: eaf6624fb7 user: sebres | |
16:24 | • Ticket [3475995fff]: 1 change artifact: b943071786 user: sebres | |
16:24 | • Ticket [3475995fff]: 5 changes artifact: 5e0db30e9d user: sebres | |
2012-01-21
| ||
20:14 | • Ticket [3475995fff]: 2 changes artifact: 1016af8d63 user: dkf | |
2012-01-19
| ||
17:59 | • Ticket [3475995fff]: 1 change artifact: 2774b06caa user: sebres | |
17:58 | • Add attachment clock.tcl.patch to ticket [3475995fff] artifact: 7891deaa46 user: sebres | |
17:58 | • Ticket [3475995fff] solved clock scan success by logical invalid date/time status still Open with 4 other changes artifact: 59d88bd026 user: sebres | |
10:58 | • New ticket [3475995fff]. artifact: 52d5f53904 user: sebres | |
Ticket UUID: | 3475995 | |||
Title: | [solved/opt] clock scan success by logical invalid date/time | |||
Type: | Bug | Version: | obsolete: 8.5.11 | |
Submitter: | sebres | Created on: | 2012-01-19 10:58:42 | |
Subsystem: | 06. Time Measurement | Assigned To: | aku | |
Priority: | 4 | Severity: | Minor | |
Status: | Open | Last Modified: | 2017-12-28 17:52:24 | |
Resolution: | None | Closed By: | nobody | |
Closed on: | ||||
Description: |
Behavior: After introducing tcl8.5 the scan does not fails on logical invalid dates like 02/30/2008 and build another date as specified : % clock format [clock scan "2008-02-30"] Sat Mar 01 00:00:00 CET 2008 % clock format [clock scan "24:62:80"] -format {%T} 23:59:59 Solution: see attached patch - patched execute : % clock format [clock scan "2008-02-30"] unable to convert date-time string "2008-02-30": invalid day while executing "clock scan "2008-02-30"" % clock format [clock scan "24:62:80"] -format {%T} unable to convert date-time string "24:62:80": invalid time while executing "clock scan "24:62:80"" To call "clock scan" without validating use this one (backwards compatible to 8.5.11): % clock format [clock scan "2008-02-30" -valid 0] Sat Mar 01 00:00:00 CET 2008 % clock format [clock scan "24:62:80" -valid 0] -format {%T} 23:59:59 The patch contains more as only this fix - example ::tcl::clock::MakeDate - to create a seconds/date dict directly (but here without date validating - see below), for example to create date from SQL-engine structures : % puts [set date [::tcl::clock::MakeDate year 2008 month 2 dayOfMonth 20 hour 0 minute 0 second 0 tzName {}]] year 2008 month 2 dayOfMonth 20 hour 0 minute 0 second 0 tzName {} era CE julianDay 2454517 secondOfDay 0 localSeconds 1203465600 seconds 1203462000 % puts "[dict get $date seconds] - [clock format [dict get $date seconds]]" 1203462000 - Wed Feb 20 00:00:00 CET 2008 To validate given date structure - use ::tcl::clock::ValidDate : % puts [set date [::tcl::clock::MakeDate year 2008 month 2 dayOfMonth 20 hour 0 minute 0 second 0 tzName {}]] year 2008 month 2 dayOfMonth 20 hour 0 minute 0 second 0 tzName {} era CE julianDay 2454517 secondOfDay 0 localSeconds 1203465600 seconds 1203462000 % ::tcl::clock::ValidDate $date {} % puts [set date [::tcl::clock::MakeDate year 2008 month 2 dayOfMonth 32 hour 0 minute 0 second 0 tzName {}]] year 2008 month 2 dayOfMonth 32 hour 0 minute 0 second 0 tzName {} era CE julianDay 2454529 secondOfDay 0 localSeconds 1204502400 seconds 1204498800 % ::tcl::clock::ValidDate $date {} unable to convert date-time string "": invalid day while executing "::tcl::clock::ValidDate $date {}" | |||
User Comments: |
sebres added on 2017-12-28 17:52:24:
Re-implemented in C for new clock-engine (tclclockmod), see github/sebres/tclclockmod#10. sebres added on 2012-02-15 17:47:28: Dkf has fixed it in core-8-5-branch. Thanks. So it's now safe within core-8-5-branch. sebres added on 2012-02-15 00:09:53: I have commited new version into http://core.tcl.tk/tcl/info/aa30a04b13 currently not safe for current development core-8-5-branch (see Artifact 3487626) safe for original tcl8.5 sebres added on 2012-02-02 16:26:14: File Added - 434679: clock.tcl sebres added on 2012-02-02 16:25:38: File Added - 434678: clock.tcl.patch sebres added on 2012-02-02 16:24:43: In addition, i have made performance patch for clock.tcl (attached) ... with up to double performance increase. Please do not forget that command "scan", compared to the standard version, also validate the date and time (i.e. additional time needed for Valid file), but nevertheless still faster in patched version. To disable this (work as original tcl) use "-valid 0" arguments. % set s [clock seconds]; puts [time {clock format $s} 50000] 38.76 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -locale de} 50000] 40.3 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale en} 50000] 28.44 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale de} 50000] 29.06 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale fr} 50000] 29.06 microseconds per iteration % % puts [time {clock scan "10/10/2011"} 50000] 40.62 microseconds per iteration % puts [time {clock scan "10/10/2011" -format %m/%d/%Y} 50000] 94.36 microseconds per iteration % puts [time {clock scan "10/10/2011" -format %m/%d/%Y -locale de} 50000] 96.56 microseconds per iteration % puts [time {clock scan "WednesdayJuly/29/1987" -format %A%B/%d/%Y -locale en} 50000] 159.7 microseconds per iteration % puts [time {clock scan "MittwochJuli/29/1987" -format %A%B/%d/%Y -locale de} 50000] 216.88 microseconds per iteration % puts [time {clock scan "mercredijuillet/29/1987" -format %A%B/%d/%Y -locale fr} 50000] 182.5 microseconds per iteration % % source {other/clock.tcl} % tcl::clock::ClearCaches % % set s [clock seconds]; puts [time {clock format $s} 50000] 22.5 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -locale de} 50000] 22.18 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale en} 50000] 18.44 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale de} 50000] 18.74 microseconds per iteration % set s [clock seconds]; puts [time {clock format $s -format %A%B/%d/%Y -locale fr} 50000] 18.44 microseconds per iteration % % puts [time {clock scan "10/10/2011"} 50000] 36.56 microseconds per iteration % puts [time {clock scan "10/10/2011" -format %m/%d/%Y} 50000] 60.62 microseconds per iteration % puts [time {clock scan "10/10/2011" -format %m/%d/%Y -locale de} 50000] 62.5 microseconds per iteration % puts [time {clock scan "WednesdayJuly/29/1987" -format %A%B/%d/%Y -locale en} 50000] 143.1 microseconds per iteration % puts [time {clock scan "MittwochJuli/29/1987" -format %A%B/%d/%Y -locale de} 50000] 176.24 microseconds per iteration % puts [time {clock scan "mercredijuillet/29/1987" -format %A%B/%d/%Y -locale fr} 50000] 147.8 microseconds per iteration sebres added on 2012-01-19 17:58:42: File Added - 433455: clock.tcl.patch |