• Re: Time conversion

    From Luc@21:1/5 to snosniv on Mon Oct 24 08:12:46 2022
    On Mon, 24 Oct 2022 03:50:27 -0700 (PDT), snosniv wrote:

    I have the following time / date string which I need to convert to
    seconds, (epoch) starting at midnight 31/12/1989 (or is it 1/1/1990).

    15 October 2022 08:05:47 >> seconds 1034755547 I think
    Is there a simple way to this using the clock function?

    TIA, Kev P.


    % clock scan "2022-10-15--08:05:47" -format "%Y-%m-%d--%H:%M:%S"
    1665831947

    % clock format 1665831947 -format "%Y-%m-%d--%H:%M:%S"
    2022-10-15--08:05:47

    This is allegedly based on the epoch time of 1 January 1970, 00:00 UTC according to the Tcl documentation. If you want to change the epoch,
    you have the -base option:

    -base time
    Specifies that any relative times present in a clock scan command are
    to be given relative to time. time must be expressed as a count of
    nominal seconds from the epoch time of 1 January 1970, 00:00 UTC.

    I'm not sure how reliable any of this is though. I copied an example
    from the wiki and got a different result.

    wiki:
    % clock scan "2000-01-01" -format "%Y-%m-%d"
    946702800

    My machine:
    % clock scan "2000-01-01" -format "%Y-%m-%d"
    946692000

    [shrug]

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From snosniv@21:1/5 to All on Mon Oct 24 03:50:27 2022
    I have the following time / date string which I need to convert to seconds, (epoch) starting at midnight 31/12/1989 (or is it 1/1/1990).

    15 October 2022 08:05:47 >> seconds 1034755547 I think
    Is there a simple way to this using the clock function?

    TIA, Kev P.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to Luc on Mon Oct 24 08:20:15 2022
    On Mon, 24 Oct 2022 08:12:46 -0300, Luc wrote:

    On Mon, 24 Oct 2022 03:50:27 -0700 (PDT), snosniv wrote:

    I have the following time / date string which I need to convert to
    seconds, (epoch) starting at midnight 31/12/1989 (or is it 1/1/1990).

    15 October 2022 08:05:47 >> seconds 1034755547 I think
    Is there a simple way to this using the clock function?

    TIA, Kev P.


    % clock scan "2022-10-15--08:05:47" -format "%Y-%m-%d--%H:%M:%S"
    1665831947

    % clock format 1665831947 -format "%Y-%m-%d--%H:%M:%S"
    2022-10-15--08:05:47

    This is allegedly based on the epoch time of 1 January 1970, 00:00 UTC according to the Tcl documentation. If you want to change the epoch,
    you have the -base option:

    -base time
    Specifies that any relative times present in a clock scan command are
    to be given relative to time. time must be expressed as a count of
    nominal seconds from the epoch time of 1 January 1970, 00:00 UTC.

    I'm not sure how reliable any of this is though. I copied an example
    from the wiki and got a different result.

    wiki:
    % clock scan "2000-01-01" -format "%Y-%m-%d"
    946702800

    My machine:
    % clock scan "2000-01-01" -format "%Y-%m-%d"
    946692000

    [shrug]


    Uh, sorry, I forgot the proof of concept:

    % clock scan "31/12/1989" -format "%d/%m/%Y"
    631072800

    % clock scan "2022-10-15--08:05:47" -format "%Y-%m-%d--%H:%M:%S" -base 631072800
    1665831947 (bingo!)


    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luc@21:1/5 to All on Mon Oct 24 08:25:52 2022
    Sorry again, now I see the number I found is very different from the one
    you expected to get.

    Either I did something wrong or you did. Likely me because I am almost
    sleeping on my chair. I've got to go to bed and put myself on the battery charger.

    Good luck.

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From snosniv@21:1/5 to Luc on Mon Oct 24 06:11:27 2022
    On Monday, 24 October 2022 at 12:25:57 UTC+1, Luc wrote:
    Sorry again, now I see the number I found is very different from the one
    you expected to get.

    Either I did something wrong or you did. Likely me because I am almost sleeping on my chair. I've got to go to bed and put myself on the battery charger.

    Good luck.

    --
    Luc

    My "Epoch" is later than the default for Tcl, I need seconds since midnight, start of new year 1990, but I can get seconds for that & subtract (hopefully).. Thanks for the help.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From snosniv@21:1/5 to snosniv on Mon Oct 24 07:34:58 2022
    On Monday, 24 October 2022 at 14:11:30 UTC+1, snosniv wrote:
    On Monday, 24 October 2022 at 12:25:57 UTC+1, Luc wrote:
    Sorry again, now I see the number I found is very different from the one you expected to get.

    Either I did something wrong or you did. Likely me because I am almost sleeping on my chair. I've got to go to bed and put myself on the battery charger.

    Good luck.

    --
    Luc

    My "Epoch" is later than the default for Tcl, I need seconds since midnight, start of new year 1990, but I can get seconds for that & subtract (hopefully).. Thanks for the help.

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