The method to get Date Tcltk
proc GetDate { args } {
#---------------------------------------------------------------
#d_sum Return the date/time appropriately formatted
#d_desc Uses Tcl clock command. Return the current time if the -clock \
argument is not used. See Tcl clock command for explanation of formats.
#d_opt0 -clock time
#d_opt1 Input a time as a machine clock time in seconds
#d_opt0 -format format
#d_opt1 Output format can be: full (%d %b %Y %H:%M:%S), time (%H:%M:%S) \
date (%d %b %Y), or brief (%H:%M:%S for today or %d %b %y)
# If there is no input secs then find the current time
# otherwise use the input time secs and convert to user
# friendly format dependent on format input
# full full date and time
# time time only
# date date only
# brief time for any time today otherwise date
#
set format full
set secs {}
set nargs [llength $args]; set n 0
while { $n < $nargs } {
switch -regexp -- [lindex $args $n] \
format {
incr n; set format [lindex $args $n]
} clock {
incr n; set secs [lindex $args $n]
}
incr n
}
if { $secs == "" } { set secs [clock seconds] }
if { [llength $secs ] > 1 } {
if { $format == "brief" } {
return [ append time [string range $secs 0 6] [string range $secs 9 10] ]
} else {
return $secs
}
}
if { $format == "seconds"} { return $secs }
if { $format == "full" } {
set date [clock format $secs -format "%d %b %Y %H:%M:%S" ]
} elseif { $format == "time" } {
set date [clock format $secs -format "%H:%M:%S" ]
} elseif { $format == "date" } {
set date [clock format $secs -format "%d %b %Y" ]
} elseif { $format == "brief" } {
set today [ clock format [clock seconds] -format "%Y %j" ]
set input [ clock format $secs -format "%Y %j" ]
if { [lindex $input 0 ] == [lindex $today 0 ] &&
[lindex $input 1 ] == [lindex $today 1 ] } {
set date [clock format $secs -format "%H:%M:%S" ]
} else {
set date [clock format $secs -format "%d %b %y" ]
}
}
return "$date"
}
"Starting CCP4I application [GetDate]"