From: SourceForge.net <no...@so...> - 2012-01-21 13:14:36
|
Bugs item #3475995, was opened at 2012-01-19 02:58 Message generated for change (Settings changed) made by dkf You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3475995&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. >Category: 06. Time Measurement Group: current: 8.5.11 Status: Open Resolution: None Priority: 3 Private: No Submitted By: sebres (sebres) >Assigned to: Kevin B KENNY (kennykb) Summary: [solved] clock scan success by logical invalid date/time Initial Comment: 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 {}" ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=3475995&group_id=10894 |