Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

time format problem

Status
Not open for further replies.

bbvic

Technical User
Oct 21, 2004
51
US
hi.
i have a question about time format.
first of all, my code reads an original text file.
after calculate time, it writes to another text file which name is write.txt

this is the result of write.txt
====================
2200,321,11:35,23:55
2201,326,12:50,24:15
2209,328,10:00,25:05
2203,325,11:00,25:05
2205,322,10:00,25:05
2206,307,9:30,25:05 (don't know why i got 9:30, not 09:30)
2207,323,10:00,25:05
2189,310,13:25,23:50
2197,318,13:15,23:45
2202,327,11:30,23:50
2204,324,10:30,25:05
=========
this is time calculation part.
###########################Start Up calculation####################################

set startUp $arrayHs4($k) ;# $before values from getvalue before$houseNumber before
set splitStartTime [split $arrayHs5($k) :]
set startTimeHourIndex [lindex $splitStartTime 0]
scan $startTimeHourIndex %d startTimeHourIndex
set startTimeHour [format "%02i" $startTimeHourIndex]
scan $startTimeHour %d startTimeHour

set startTimeMinIndex [lindex $splitStartTime 1]
scan $startTimeMinIndex %d startTimeMinIndex
set startTimeMin [format "%02i" $startTimeMinIndex]
scan $startTimeMin %d startTimeMin
# first movie - startUp minute
set calMin [expr $startTimeMin - $startUp]

if {$calMin >= 0} {
set occupiedTimeMin "$calMin"
scan $occupiedTimeMin %d occupiedTimeMin

if {$occupiedTimeMin <10} {

set occupiedTimeMin [format "%02i" $occupiedTimeMin]
scan $occupiedTimeMin %d occupiedTimeMin

#set occupiedTimeReg "$startTimeHour:$occupiedTimeMin"
set occupiedTimeReg [format "%02i:%02i" $startTimeHour $occupiedTimeMin]

}
set occupiedTimeReg [format "%02i:%02i" $startTimeHour $occupiedTimeMin]

} else {
set occupiedTimeHour [expr $startTimeHour - 1]
set occupiedTimeMin "[expr $calMin + 60]"
scan $occupiedTimeMin %d occupiedTimeMin
if {$occupiedTimeMin <10} {
#set occupiedTimeMin "0$occupiedTimeMin" ;# Time (min) format
set occupiedTimeMin [format "%02i" $occupiedTimeMin]
scan $occupiedTimeMin %d occupiedTimeMin
set occupiedTimeReg [format "%02i:%02i" $occupiedTimeHour $occupiedTimeMin]

}
set occupiedTimeReg "$occupiedTimeHour:$occupiedTimeMin"
set occupiedTimeReg [format "%02i:%02i" $occupiedTimeHour $occupiedTimeMin]

}
----------------

would you please help me why i got 9:30 instead of 09:30?

Thank you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top