Version 4 of Free-format clock scan

Updated 2007-02-15 13:02:04 by LV

See http://purl.org/tcl/home/man/tcl8.5/TclCmd/clock.htm

In 8.5, the old (up to 8.4) clock scan command is deprecated in favour of the new clock scan -format.

This is covered by TIP #173 [L1 ], and I understand the reasons behind creating the new version, but I think it would be a great pity to lose a great usability aid for applications that use dates - an easy way of letting the user type in "yesterday" or "last week". I may be missing something, but I can't see any way to deal with this in the new version.

I guess what I am really saying is, deprecate it if you like, but don't ever take the old code out.


LV

 set EASTERN ":America/New_York"
 set s [clock scan now -timezone $EASTERN ]
 set yesterday [clock add $s -1 day -timezone $EASTERN]
 set x [clock format $yesterday -timezone $EASTERN]
 puts $x

Of course, you don't have to do things as seperate calls - you can do it as all one call.

 set nextweek [clock add $s 1 week -timezone $EASTERN]
 set x [clock format $nextweek -timezone $EASTERN]

The clock add should provide most, if not more, capability of the old freeform clock scan, with the downside of using a slightly different notation.


[ Category Date and Time ]