Version 0 of clock forward compatibility

Updated 2001-04-23 22:26:42

if {package vcompare [package provide Tcl 8] < 0} {

    # There is a bug in [clock format] (fixed in Tcl 7.6p2) which causes it
    # to fail if the value of the -format option does not contain a '%'.
    rename clock Tcl7.6_clock
    ;proc clock {option args} {
        switch -glob -- $option {
            f* {
                if {[string first $option format] != 0} {
                    return [uplevel [list Tcl7.6_clock $option] $args]
                }
                array set tmp [lrange $args 1 end]
                if {[catch {regexp % $tmp(-format)} hasPercent] || $hasPercent} {
                    return [uplevel [list Tcl7.6_clock $option] $args]
                } else {
                    return $tmp(-format)
                }
            }
            default {
                uplevel [list Tcl7.6_clock $option] $args
            }
        }
    }

  }