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.
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]
Sorry again, now I see the number I found is very different from the oneMy "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.
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
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.
--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.
Luc
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 26:25:44 |
| Calls: | 12,106 |
| Calls today: | 6 |
| Files: | 15,006 |
| Messages: | 6,518,193 |