Re: Getting GMT time



Bryan Oakley wrote:
Anonymous AtWork wrote:

Bryan Oakley wrote:

Anonymous AtWork wrote:

I want to know what the GMT time is.  ...
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.


The only difference in time between here (pick your own definition for "here) and GMT is the formatting, so I'm not sure what you're asking.

How is what I suggested not what you want? Does the following code print something that is unexpected for you?

  % set now [clock seconds]
  1135889846
  % clock format $now
  Thu Dec 29 14:57:26 -0600 2005
  % clock format $now -gmt 1
  Thu Dec 29 20:57:26 +0000 2005

Sorry, I was incredibly unclear, mostly because I didn't even know what I wanted.


[clock seconds] returns a number of seconds. I format those seconds to my local timezone. Then I remove the TZ designation and pretend that it is a GMT time. I turn that GMT time into a number of seconds.

Obviously I can do this with string manipulation, I was just wondering if there was a to do it with [clock], like if it could return how many seconds from GMT my localtime is. But now that I lay it all out like that, I realize just how ugly this is (it was a workaround to another problem). I've since just fixed the issue I was trying to work around in the first place.

Sorry, everyone!
.



Relevant Pages

  • LC_TIME (Was: Re: Why with seconds?)
    ... not [clock scan], and didn't actually function on all platforms. ... The result that [clock format] would ... To make the locale available to applications, ...
    (comp.lang.tcl)
  • confusing [clock] behavior
    ... understand a [clock] behavior. ... stamp to be used in log files. ... % set now [clock format [clock seconds]] ... $ TZ=GMT+6 LANG=C tclsh ...
    (comp.lang.tcl)
  • Re: Bug in clock in current CVS?
    ... After another CVS update and a full rebuild, ... clock seconds works as expected. ... I had clock format, but not clock seconds ... >>I suspect that if the namespace does not exist, ...
    (comp.lang.tcl)
  • Re: winter and summer time confusion in clock and tcl 8.4.12 and 8.5a4 (starpack)
    ... I'm not on the boundary of daylight savings time, ... like e.g. today) must cause "clock scan" to return the real, ... % clock format ... Thu Mar 30 16:10:05 CEST 2006 ...
    (comp.lang.tcl)
  • Re: fooled by shifting date
    ... I've always believed that [clock ... physical time elapsed since Jan 1 1970), and that only [clock format] ... (in France, CET timezone) ... Since DST is then only a view of strftime/, ...
    (comp.lang.tcl)