Re: Getting GMT time
- From: Stefaan <nws327349@xxxxxxxxx>
- Date: Sat, 31 Dec 2005 12:06:16 +0100
Anonymous AtWork wrote:
Bryan Oakley wrote:
Anonymous AtWork wrote:
I want to know what the GMT time is. If I do [clock seconds], I get the local time. I can add 5 hours, but what about DST when it is 6 (or 4--whatever the difference is). There's probably some kind of non-portable craziness I could do to find out what TZ the computer is in and figure out the local algorithm for adjustment thereof, but since Tcl already knows all that (right?) it seems like it could do it for me.
Is there a simple, 2-3 line way to do this?
Look at the clock man page, especially where it mentions the -gmt option to "clock format".
That will *format* the number of seconds I have as a GMT time. But the number of seconds I have isn't GMT, it's local. Given the local time, I want to know the GMT time.
I use following algoritm to determine the GMT time to calculate planet positions
## let t be the local time set t [clock seconds] 1136026469
clock format $t -format "%Y-%m-%d %H:%M:%S" 2005-12-31 11:54:29 ## Belgium is GMT+1
clock format $t -format "%Y-%m-%d %H:%M:%S" -gmt 1 2005-12-31 10:54:29
## Following command will convert the local time t to GMT time
clock scan [clock format $t -format "%Y-%m-%d %H:%M:%S" -gmt 1] 1136022869 .
- Follow-Ups:
- Re: Getting GMT time
- From: Kevin Kenny
- Re: Getting GMT time
- References:
- Getting GMT time
- From: Anonymous AtWork
- Re: Getting GMT time
- From: Bryan Oakley
- Re: Getting GMT time
- From: Anonymous AtWork
- Getting GMT time
- Prev by Date: Re: Tcl vs. Lua
- Next by Date: Re: Who gets a newsgroup?
- Previous by thread: Re: Getting GMT time
- Next by thread: Re: Getting GMT time
- Index(es):
Relevant Pages
|