Paul Medeiros <
medei...@gmail.com> wrote:
> The following command:
> clock format [clock scan "38:00 01/48/2016" -format "%R %D"] -format "%R %D"
> Results in: 14:00 02/18/2016
> Is clock scan really this broken? I have tried various format strings,
> but clock scan never throws an error when I give it invalid dates.
> It doesn't know that there are not 38 hours in a day and no month
> has 48 days?
It knows, as you can see by that it wraps the extra days into next
month, and extra hours into next day.
You probably mix up date conversion with date validation. Tcl only
does the former.
If you're working with fixed format, you could also construct a
scan format, and validate the fields, before passing them to
clock.
> I gave up on clock scan and now use [exec date ...] (on linux).
> I wonder if this is a well known problem/feature or have
> I misunderstood something.
Java's "SimpleDateFormat" has a boolean attribute to request strict
or lenient parsing. Tcl only has lenient parsing. Feel free to
write a TIP for a flag (for clock scan) to trigger strict parsing.