Sujet : Re: what's the best way to get today at 00:00:00?
De : saitology9 (at) *nospam* gmail.com (saito)
Groupes : comp.lang.tclDate : 24. Jul 2025, 17:48:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <105to45$oppc$2@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 7/24/2025 4:02 AM, Mark Summerfield wrote:
I have a function that returns today's date/time at 00:00:00, e.g.,
2025-07-24T00:00:00, returned as seconds:
proc start_of_day {} {
clock scan "[clock format now -format %Y]-[clock format now \
-format %m]-[clock format now -format %d]" -format "%Y-%m-%d"
}
Is there a better way?
I am curious why a better way? It doesn't seem that heavy or slow.
However, you can make it more "robust". It is possible that on a Dec 31, 2024, you will get 2024-Jan-01T00:00:00 because you are treating 3 different time points as "now". After the firs call for the year, the clock may switch to the next year.