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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL procedure 'clock'

Status
Not open for further replies.

fhutt

Programmer
Jul 7, 2006
79
0
0
AU
Hello
I have been looking at the clock procedure for my purpose.
I have used the 'file mtime $filename' to obtain an integer of the file modification date and time. I need to convert this to a more readable format and I think that the 'clock' procedure can do this.

Also, if I have a date and time, I would like to convert this to the integer format so that I can issue the 'file mtime $filename $integer' procedure to change the file date and time.
Could someone please help with suggestions with these 2 clock formatting problems?
Thanks
 
I think I worked out a solution:

set val [file mtime $filename]
set form [clock format $val -format "%d-%b-%Y %T"]
(SOME DISPLAY PROCEDURE AND CHANGE DATE AND TIME PROCEDURE)
set valnew [clock scan $form]
file mtime $filename $valnew

Here the variable 'form' contains the string as an example '18-Jul-2011 10:24:38'. This variable may now be displayed and is then used to apply to the clock scan procedure to produce the 'valnew' variable containing the integer that can be applied to the 'file mtime $filename $valnew' procedure to set the date and time of the file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top