Problem clock scan "ccyymmdd hhmm" when hh="00"
Author Message
Problem clock scan "ccyymmdd hhmm" when hh="00"

This works: clock scan "20060117 0130"
This fails: clock scan "20060117 0030"
The man page says it supports time in hhmm format and works for all
hours except "00".
When using hours as "00", clock scan interprets minutes as hours for mm
up to 23, then for mm> 23 fails:
clock scan "20060117 00\$mm"

Now if you append another "00" onto hhmm, it seems to work but the man
page does not really say that a time format of "hhmmss" is valid.

We use a lot of file names tagged with ccyymmdd_hhmm. So is it safe to
just append another "00" for seconds or would it be best to separate
hours and minutes with ":" for use with clock scan?

Sun, 06 Jul 2008 01:41:34 GMT
Problem clock scan "ccyymmdd hhmm" when hh="00"
On Tue, 17 Jan 2006 18:41:34 +0100, max vorticity

Quote:

> This works: clock scan "20060117 0130"
> This fails: clock scan "20060117 0030"
> The man page says it supports time in hhmm format and works for all
> hours except "00".
> When using hours as "00", clock scan interprets minutes as hours for mm
> up to 23, then for mm> 23 fails:
> clock scan "20060117 00\$mm"

> Now if you append another "00" onto hhmm, it seems to work but the man
> page does not really say that a time format of "hhmmss" is valid.

> We use a lot of file names tagged with ccyymmdd_hhmm. So is it safe to
> just append another "00" for seconds or would it be best to separate
> hours and minutes with ":" for use with clock scan?

Why not just do

regexp {^([0-9]{4})([0-9]{2})([0-9]{2}) ([0-9]{2})([0-9]{2})\$} \$time -
year month day hour minute

set clk [clock scan "\$year-\$month-\$day \${hour}:\${minute}"]

This will definitely work.

Effort on converting all possible ?yy?yymmddhhmm?ss? with and without
separators into a clock scan valid value is a good subject for a wiki page
actually :-)

--
WK

Sun, 06 Jul 2008 03:41:00 GMT
Problem clock scan "ccyymmdd hhmm" when hh="00"
FWIW, this is fixed in Tcl 8.5, where you can also specify an explicit
format to [clock scan] (i.e. "%Y%m%d %H%M").

Sun, 06 Jul 2008 04:16:17 GMT
Problem clock scan "ccyymmdd hhmm" when hh="00"
My problem is not really with how to accomplish the decoding of this
date format, but I guess I was wondering if this is a bug or I'm not
using clock scan correctly.  And if time in hhmmss is really valid or
subject to break in a future version.

However, what would be really nice is: clock scan dateString  ?-format
formatString? where dateString is parsed according to formatString (as
in clock format)...

Sun, 06 Jul 2008 04:30:58 GMT
Problem clock scan "ccyymmdd hhmm" when hh="00"
Quote:

> FWIW, this is fixed in Tcl 8.5, where you can also specify an explicit
> format to [clock scan] (i.e. "%Y%m%d %H%M").

yippii, horay!

uwe

Sun, 06 Jul 2008 07:00:06 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages