See http://purl.org/tcl/home/man/tcl8.4/TclCmd/clock.htm for the formal man page.
Example:
%clock format [clock seconds] -format %Y-%m-%dT%H:%M:%S
returns an ISO8601 [L1 ] formatted timestamp, such as:
2006-06-24T09:48:29
JMN 2006-06-24
[clock format] doesn't directly allow you to produce an ISO8601 timestamp that includes fractional seconds - you have to tack that on yourself because [clock format] expects an integer number of seconds. I guess you can just grab the last 3 digits of [clock milliseconds] and tack them on with the '.' separator.
Recent implementations (e.g Tcl 8.5a4) of [clock format] show a fivefold slow-down in comparison to Tcl 8.4.
e.g now roughly 0.5 milliseconds per [clock format] on an old 400MHZ machine
While I understand this is due to the long overdue Reworking the clock command - and the current implementation is pure Tcl.. Can we expect an improvement of the performance of this?
I think this is actually quite important. Many systems use timestamps extensively - and also need to extract fields (year,minute etc) relatively quickly. e.g Logging systems, mail handling protocols, certain object-oriented models.
[clock format] in Tcl8.5 now accepts extra options such as -timezone. See http://purl.org/tcl/home/man/tcl8.5/TclCmd/clock.htm for the formal man page.
Is all this extra timezone stuff going to cost us in terms of performance? If so - would it make sense to have a separate command for fast extraction of basic timestamp fields - without the complication of timezones? i.e treat the provided timestamp as TAI and the caller can use [expr] to add the relevant timezone offset before formatting if they need to. (Maybe some other command could then be made available to calculate offsets that account for timezones and leap-seconds?)
e.g something like
[[clock fields [clock milliseconds] -resolution milliseconds]
returning a minimal fixed order list suitable for use by [array set] or [lindex], [lassign] etc.
{year 2006 month 06 day 24 hour 09 min 48 sec 29 millisec 11}
See also: clock & Parsing ISO8601 dates and times [L2 ]