• Re: what's the best way to get today at 00:00:00?

    From rene@21:1/5 to All on Thu Jul 24 08:24:53 2025
    Mark Summerfield <[email protected]> posted:

    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?
    clock scan [clock format now -format %Y-%m-%d]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From EvoTcl@21:1/5 to Mark Summerfield on Thu Jul 24 02:19:17 2025
    On 7/24/25 01:02, Mark Summerfield wrote:

    Is there a better way?

    What about [clock scan "today 00:00:00"] ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Mark Summerfield on Thu Jul 24 13:55:59 2025
    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"]
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Rich on Thu Jul 24 16:31:10 2025
    Rich <[email protected]d> wrote:
    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"]
    }

    Ah, missed the "returned as seconds".

    proc start_of_day {} {
    return [clock scan [clock format [clock seconds] -format "%Y-%m-%dT00:00:00"] -format %Y-%m-%dT%H:%M:%S]
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to saito on Thu Jul 24 20:02:06 2025
    saito <[email protected]> wrote:
    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.

    Sadly, these "highly unlikely" items are just the things to come out of (seemingly) nowhere after the code's been running for years, and then,
    one time, on Dec 31 the planets align "just right" and the process goes
    "boom".

    Only by then, no one knows why, and possibly, the original author has
    also moved on to elsewhere.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to EvoTcl on Sat Jul 26 22:28:31 2025
    On 24/07/2025 11:19, EvoTcl wrote:
    On 7/24/25 01:02, Mark Summerfield wrote:

    Is there a better way?

    What about [clock scan "today 00:00:00"] ?

    This uses free-format scan, which the manual page says is deprecated.
    The non-deprecated version would be: [clock scan 00:00:00 -format %T].
    You can add the -base option if you want something other than today. But
    -base defaults to now, so it is unnecessary for "today".


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)