Updated 2016-09-26 10:55:45 by pooryorick

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

This is covered by TIP 173, 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 end 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.

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 separate 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]

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


I'm sure I could code anything I need, but I was actually talking about end-users, who would rather type in "yesterday" or "last week" or "13 jan" or "jan 13" than select from a popup calendar - at the moment I just pass their input to clock scan, what would I have to do if it wasn't there?

slebetman: Agreed. Configuration files for most of my apps allows users to enter things this way when specifying time or time interval. Having to handle this myself means that I have to write a proc that handles possibly hundreds of cases for:
  1 hour
  5 hours 20 seconds
  next week

It's nice that clock scan already does this for me.