I have a function that returns today's date/time at 00:00:00, e.g., 2025-07-24T00:00:00, returned as seconds:clock scan [clock format now -format %Y-%m-%d]
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?
Is there a better way?
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?
Mark Summerfield <[email protected]> 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?
proc start_of_day {} {
return [clock format [clock seconds] -format "%Y-%m-%dT00:00:00"]
}
On 7/24/2025 12:48 PM, saito wrote:
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.
Well, it is highly unlikely, with chances being slimmer thank winning
the mega lottery.
On 7/24/25 01:02, Mark Summerfield wrote:
Is there a better way?
What about [clock scan "today 00:00:00"] ?
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 144:07:20 |
| Calls: | 12,089 |
| Calls today: | 2 |
| Files: | 15,000 |
| Messages: | 6,517,483 |