From: r_haertel on
Hello,

I have a table with timestamps (clock seconds). I now want to find all
timestamps from a specific week. For this I need to know the start of
the week in seconds and the end of the week in seconds.

I thought the clock scan (Tcl 8.5) would do this. But it doesn't work
as I expect it. The documentation says:

%V ....
On input, accepts the ISO8601 week number.

So the following code should give the seconds of the week. Maybe not
the start of the week but at least seconds that lie within the week.

for {set week 0} {$week < 22} {incr week} {
set x [clock scan "$week 2008" -format "%U %Y"]
puts [clock format $x]
}

Am I missing something? or is it a bug?

Rüdiger
From: tom.rmadilo on
On Jul 3, 11:15 pm, r_haer...(a)gmx.de wrote:
> Hello,
>
> I have a table with timestamps (clock seconds). I now want to find all
> timestamps from a specific week. For this I need to know the start of
> the week in seconds and the end of the week in seconds.
>
> I thought the clock scan (Tcl 8.5) would do this. But it doesn't work
> as I expect it. The documentation says:
>
>  %V     ....
>               On  input,  accepts the ISO8601 week number.
>
> So the following code should give the seconds of the week. Maybe not
> the start of the week but at least seconds that lie within the week.
>
> for {set week 0} {$week < 22} {incr week} {
>     set x [clock scan "$week 2008" -format "%U %Y"]
>     puts [clock format $x]
>
> }
>
> Am I missing something? or is it a bug?

Thinking in seconds is a bug. Seconds represent a division of time,
not a building block.
From: Alexandre Ferrieux on
On Jul 4, 8:15 am, r_haer...(a)gmx.de wrote:
> Hello,
>
> I have a table with timestamps (clock seconds). I now want to find all
> timestamps from a specific week. For this I need to know the start of
> the week in seconds and the end of the week in seconds.
>
> I thought the clock scan (Tcl 8.5) would do this. But it doesn't work
> as I expect it. The documentation says:
>
> %V ....
> On input, accepts the ISO8601 week number.
>
> So the following code should give the seconds of the week. Maybe not
> the start of the week but at least seconds that lie within the week.
>
> for {set week 0} {$week < 22} {incr week} {
> set x [clock scan "$week 2008" -format "%U %Y"]
> puts [clock format $x]
>
> }
> Am I missing something? or is it a bug?

Hm, you're right, there's something fishy in the handling of the
iso8601week on input in clock.tcl. Could you file a bug report ?

In the meantime, the output direction seems to work, so you can use
[clock format ... -format "%Y %V"] and a dict or array to implement
the inversion.

-Alex
From: Alexandre Ferrieux on
On Jul 4, 10:52 am, Alexandre Ferrieux <alexandre.ferri...(a)gmail.com>
wrote:
> On Jul 4, 8:15 am, r_haer...(a)gmx.de wrote:
>
>
>
> > Hello,
>
> > I have a table with timestamps (clock seconds). I now want to find all
> > timestamps from a specific week. For this I need to know the start of
> > the week in seconds and the end of the week in seconds.
>
> > I thought the clock scan (Tcl 8.5) would do this. But it doesn't work
> > as I expect it. The documentation says:
>
> > %V ....
> > On input, accepts the ISO8601 week number.
>
> > So the following code should give the seconds of the week. Maybe not
> > the start of the week but at least seconds that lie within the week.
>
> > for {set week 0} {$week < 22} {incr week} {
> > set x [clock scan "$week 2008" -format "%U %Y"]
> > puts [clock format $x]
>
> > }
> > Am I missing something? or is it a bug?
>
> Hm, you're right, there's something fishy in the handling of the
> iso8601week on input in clock.tcl. Could you file a bug report ?
>
> In the meantime, the output direction seems to work, so you can use
> [clock format ... -format "%Y %V"] and a dict or array to implement
> the inversion.

As another workaround, if you provide the day-of-week (%A), then %V
seems to work on input too:

clock scan "01 Thu 2008" -format "%V %A %Y"

So the bug seems to be in the handling of the absence of day-of-the-
week.

-Alex
From: Andreas Leitgeb on
r_haertel(a)gmx.de <r_haertel(a)gmx.de> wrote:
> for {set week 0} {$week < 22} {incr week} {
> set x [clock scan "$week 2008" -format "%U %Y"]
> puts [clock format $x]
> }
Gives me current date at midnight for each week.

There is a small typo in your snippet, by which it uses
%U instead of %V, (%U is documented to be ignored for
input!), but the same symptom also shows up for %V,
and that *is* bug. ("On input, %V accepts the ISO8601
week number.")

> Am I missing something? or is it a bug?

I'd say it's a bug for %V, but not a bug for %U.

Also, I disagree with tom.rmadilo about the usage of seconds.
I think your task is absolutely reasonable. For [clock], secs
*are* the building blocks of all time&date arithmetics.
Perhaps, tom misunderstood your problem (or I do :-).

 |  Next  |  Last
Pages: 1 2
Prev: after ids
Next: Ann: kbs 0.2.3