This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

using the clock

Old posts that have not been replied to for several years.
Locked
B
BrollY
Voice
Posts: 36
Joined: Wed Apr 23, 2003 9:28 pm
Location: H07 L471N4 L4ND (Puerto Rico)

using the clock

Post by BrollY »

well, so far i just learned how to return the current date and local time with the clock format thing, but i was wondering if there was a way to check the time in another part of the country, or atleast pretend to do it.

for example, my timezone is AST, which is the same as EST when DST isnt applied, n i want the bot to display the current CET time (which is 6 hours ahead of me without DST), how would i go about making the bot display the time 6 hours ahead, as if it was CET.

i dont think many will understand this from the first try at reading it, i just seriously suck with explanations
Yo momma's so fat she can be in the past, present, n future all at once
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The only way to go about this, it to do a bit of Math.

Code: Select all

set timehere [clock seconds]

set format [clock format [expr ((6 * 60) * 60) + $timehere]]
As you can see, you add 6 hours onto the time.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Read about 'clock format' in the manual... I suggest something like this:

set diff 6

then:

clock format [clock scan ${diff}hour] -format %T

or:

clock format [expr [clock seconds]+($diff*3600)] -format %T

There might be better ways, though... Take a look at this man page http://tcl.tk/man/tcl8.4/TclCmd/clock.htm


Edit: damn...when will i learn to reload to check if other people have answered before i post :P
As you can see, I did the same math as ppslim in my last example.
B
BrollY
Voice
Posts: 36
Joined: Wed Apr 23, 2003 9:28 pm
Location: H07 L471N4 L4ND (Puerto Rico)

Post by BrollY »

thanks for the help

btw, i changed ppslims code to this

set timehere [clock seconds]
set format [clock format [expr ((6 * 60) * 60) + $timehere] -format "little letters here"]


that being wat i was looking for but works fine, thanks a bunch
Yo momma's so fat she can be in the past, present, n future all at once
Locked