How to calculate the time span in Tcl using clock commands

Viewed 3803

I need to calculate the time difference between two periods of a day in a 24:00 hr format clock using Tcl.

Let's say my start time is 06:30:00 in the morning and end time is 18:30:00 in the evening. I've tried the following in using Active Tcl 8.5 and 8.6 in windows.

set morn [clock scan 06:30:00 -format %H:%M:%S]
set even [clock scan 18:30:00 -format %H:%M:%S]
set diff [clock format [expr $even - $morn ] -format %H:%M:%S]

The answer is supposed to be 12:00:00 which is the actual difference but, I get the answer as 17:30:00 which is totally confusing.

I presume that the GMT time difference of 05:30:00 is being added to the difference as I'm in a GMT+5:30 time zone (IST).

How do I get the exact difference?

2 Answers
Related