Overview
| Artifact ID: | d9e89b442fd699a7ec22cd1f07956de7babe6c98053b6ce886d82b504c98047a |
|---|---|
| Ticket: | 3475995fffffffffffffffffffffffffffffffff
[solved/opt] clock scan success by logical invalid date/time |
| User & Date: | sebres on 2017-12-28 17:52:24 |
Changes
- assignee changed to: "aku"
- closer changed to: "nobody"
- comment changed to:
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 {}" - icomment:
Re-implemented in C for new clock-engine (tclclockmod), see <a href="https://github.com/sebres/tclclockmod/pull/10">github/sebres/tclclockmod#10</a>.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- severity changed to: "Minor"