Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5085853c52429b482e648bd2a8d4ed9d6958c3714958cd7e4d264fc2a413973d
Ticket: 3ee8f1c2a785f4d8bd0ca60f1076cee78ebb3255
Clock scan issues with validation disabled.
User & Date: sbron on 2024-07-15 09:47:57
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    In my code, I frequently use the following method to get the epoch time of the next midnight:
    
    	set midnight [clock scan 24:00:00 -format %T]
    
    In Tcl 9.0 that currently throws an error. Apparently I need to use the option -validate 0 to allow the Tcl 8.6 behavior.
    
    First of all, there is no mention of the -validate option in the clock manual page. [TIP #688](https://core.tcl-lang.org/tips/doc/trunk/tip/688.md) claims that the default value for the -validate option is 0. In practice it seems to actually be 1.
    
    However, the biggest problem is that the produced value is incorrect. Clearly 24:00:00 should be 1 second after 23:59:59. But that is not the case. I wrote the following test script:
    
    	if {[package vsatisfies [package present Tcl] 9]} {
    	    set novalidate {-validate 0}
    	} else {
    	    set novalidate {}
    	}
    
    	set sec1 [clock scan 23:59:59 -format %T {*}$novalidate]
    	set sec2 [clock scan 24:00:00 -format %T {*}$novalidate]
    
    	puts [expr {$sec2 - $sec1}]
    
    In Tcl 8.6 this produces a result of 1, as expected. In Tcl 9.0 it reports -86400 (possibly depending on the day of the week the script is executed).
    
  5. foundin changed to: "3d8bf31bdc"
  6. is_private changed to: "0"
  7. login: "sbron"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "8475f421649231f1e116ac602bea4537d2b027b4"
  10. resolution changed to: "None"
  11. severity changed to: "Critical"
  12. status changed to: "Open"
  13. submitter changed to: "sbron"
  14. subsystem changed to: "16. Commands A-H"
  15. title changed to: "Clock scan issues with validation disabled."
  16. type changed to: "Bug"