Getting number of months would be 'whole months', days would be 'whole
days', etc.
That means (assuming you have a function 'timespan' like I'd want):
timespan days {2006-01-01 12:00:00} {2006-02-01 12:00:00}
result: 31
timespan days {2006-02-01 12:00:00} {2006-03-01 12:00:00}
result: 28 (but on a leap year it would be 29)
set t [timespan expr { {2006-02-01 12:00:00} + {28 days} + {5 seconds} }]
clock format $t -format "%Y:%m:%d %H:%M%S"
result: 2006-03-01 12:00:05
set t [timespan expr { {2006-03-01 12:00:00} + {28 days} + {5 seconds} }]
clock format $t -format "%Y:%m:%d %H:%M%S"
result: 2006-03-28 12:00:05
Lisa
"Roy Terry" <royterry@earthlink.net> wrote in message
news:UH_Lf.734$6I.636@newsread3.news.pas.earthlink.net...
> "Lisa Pearlson" <no@spam.plz> wrote in message
> news:43ff5fe9$0$8260$e4fe514c@dreader30.news.xs4all.nl...
>> Hi,
>>
>> I have 2 dates, formatted like "yyyy-mm-dd hh:mm:ss".
>>
>> I wish to know the difference between the two, in seconds, hours, days,
>> months and years.
>>
>> I looked at clock function.. I can use [clock scan $dt] on these days and
>> get platform specific seconds or something.
>
> Actually it will give you a universal time coordinate.
>
> I can subtract these dates from
>> one another (larger from the smaller), and format this into a date. But
> this
>> will give me the time offset from epoch.
> I don't think so. If you subtract the two values you will get nothing
> but a pure count of seconds.
>
> And as such it doesn't take into
>> account the actual dates of which I am wanting to know the difference
> off..
> Not correct. It is pure seconds that give you the exact difference.
>
>> This is important if I want to know the difference in these two dates in
>> number of months, since not all months are created equal.
>
> How would you define a difference in months? Would
> it only include whole months?
>>
>> There ought to be some type of timespan function:
>>
>> set td1 {2006-01-01 12:00:00}
>> set td2 {2006-02-24 20:00:00}
>>
>> set months [timespan months $t1 $t2]
>> set seconds [timespan seconds $t1 $t2]
>>
>> Can something like this be accomplished in TCL?
> I think so depending on your
> defiinition month differences.
>
>
>
>>
>> Lisa
>>
>>
>
>
Received on Sun Apr 30 02:16:07 2006