tcl dates - weird bug or am I going insane??? 
Author Message
 tcl dates - weird bug or am I going insane???

Greetings all...

I think I'm losing it. I'm writing a utility that takes a user entered
date, adds 13 days to it to get one value, then adds 4 days to that to
get the end value. Example: users enters 1/1/2001, I return 1/14/2001
- 1/18/2001. I'm using the folowing code to determine these values:

# convert user entered date
set tclDate [clock scan [SHOW date]]

# add 12 days
set firstOvDay_$i [expr [SHOW tclDate] + 1123200]

# add 4 more days
set lastOvDay_$i [expr [clock scan [SHOW firstOvDayFormated_[SHOW i]]]
+ [expr 4 * 86400]]

And this works everytime...except when I use a date between 10/12 and
10/16 (year doesn't matter!)

Thoughts????



Mon, 15 Mar 2004 02:31:16 GMT  
 tcl dates - weird bug or am I going insane???
Your problem appears to be daylight savings time.
Use [clock] to calculate your relative times.

    % set date 10/13/2001
    % clock format [set tcldate [clock scan $date]]
    Sat Oct 13 00:00:00 EDT 2001
    % #                 ^^^
    % clock format [set firstOvDay [clock scan "13 days" -base $tcldate]]
    Fri Oct 26 00:00:00 EDT 2001
    % #                 ^^^
    % clock format [set lastOvDay [clock scan "4 days" -base $firstOvDay]]
    Tue Oct 30 00:00:00 EST 2001
    % #                 ^^^

Using a variable name like "set firstOvDay_$i ..." indicates you might
want to use an array instead: "set firstOvDay($i) ...".  It'll
make dereferencing easier:  use $firstOvDay($i) instead of
[set firstOvDay_[set i]]


Quote:
>Greetings all...

>I think I'm losing it. I'm writing a utility that takes a user entered
>date, adds 13 days to it to get one value, then adds 4 days to that to
>get the end value. Example: users enters 1/1/2001, I return 1/14/2001
>- 1/18/2001. I'm using the folowing code to determine these values:

># convert user entered date
>set tclDate [clock scan [SHOW date]]

># add 12 days
>set firstOvDay_$i [expr [SHOW tclDate] + 1123200]

># add 4 more days
>set lastOvDay_$i [expr [clock scan [SHOW firstOvDayFormated_[SHOW i]]]
>+ [expr 4 * 86400]]

>And this works everytime...except when I use a date between 10/12 and
>10/16 (year doesn't matter!)

>Thoughts????

--
Glenn Jackman


Mon, 15 Mar 2004 03:18:20 GMT  
 tcl dates - weird bug or am I going insane???


Quote:
> Greetings all...

> I think I'm losing it. I'm writing a utility that takes a user entered
> date, adds 13 days to it to get one value, then adds 4 days to that to
> get the end value. Example: users enters 1/1/2001, I return 1/14/2001
> - 1/18/2001. I'm using the folowing code to determine these values:

> # convert user entered date
> set tclDate [clock scan [SHOW date]]

> # add 12 days
> set firstOvDay_$i [expr [SHOW tclDate] + 1123200]

> # add 4 more days
> set lastOvDay_$i [expr [clock scan [SHOW firstOvDayFormated_[SHOW i]]]
> + [expr 4 * 86400]]

> And this works everytime...except when I use a date between 10/12 and
> 10/16 (year doesn't matter!)

What order did you use here, day/month or month/day ?

If month/day it would be october and could be the DST switch throwing you
off.
I guess you add exactly 12*(seconds-per-day) but when it comes to DST this
is
one hour less than is required to get into the next day.

--




Mon, 15 Mar 2004 04:25:32 GMT  
 tcl dates - weird bug or am I going insane???


:And this works everytime...except when I use a date between 10/12 and
:10/16 (year doesn't matter!)

I would suspect that you would find similar behavior during either March or
April of each year...

--
--
"I know of vanishingly few people ... who choose to use ksh." "I'm a minority!"

Even if explicitly stated to the contrary, nothing in this posting



Tue, 16 Mar 2004 22:03:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Tk in C: I am going insane

2. Am I completely insane?...

3. Running CGIs under my uid - going slowly insane.

4. weird arithmetic, what am I doing wrong

5. weird arithmetic, what am I doing wrong?

6. Weird Problem--align toolbox Poof Gone!

7. sound gone weird

8. weird date problem

9. I am going to start assembly programming

10. am i gonna go down in flames??

11. Am stupid and now going crazy...

12. Tcl Date Routines don't handle ISO date formats

 

 
Powered by phpBB® Forum Software