Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TIP? %F for clock format

37 views
Skip to first unread message

Cecil Westerhof

unread,
Dec 18, 2017, 7:44:06 AM12/18/17
to
I started working with TCL and I like it a lot. Much better as Bash
what I was using a lot. But I am used to use %F with date. From the
man page:
%F full date; same as %Y-%m-%d

Could that be added?

By the way: very nice that the switch does not need a break. ;-)

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

jima

unread,
Dec 18, 2017, 8:31:08 AM12/18/17
to
In the meantime, you can have it straight away:

set F %Y-%m-%d
clock format [clock seconds] -format $F

:-)

jima

jima

unread,
Dec 18, 2017, 9:46:17 AM12/18/17
to
A better version contributed by emiliano on the Tcl Chat. By the way, I recommend you to visit it... (http://wiki.tcl.tk/2619)

catch {clock format}
rename ::tcl::clock::format ::tcl::clock::_format
proc ::tcl::clock::format {clockval args} {
if {([llength $args] % 2 == 0) && "-format" in [dict keys $args]} {
dict set args -format \
[string map {%F {%Y-%m-%d}} [dict get $args -format]]
}
tailcall _format $clockval {*}$args
}

$ clock format [clock seconds] -format %F
2017-12-18

Cecil Westerhof

unread,
Dec 18, 2017, 10:28:06 AM12/18/17
to
Works likes a charm. Thanks.
0 new messages