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.

Displaying the time...

Old posts that have not been replied to for several years.
Locked
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Displaying the time...

Post by NewzUK »

Hi - I have this script that plays to the channel at the top of every hour:

bind time - "00 * * * *" put:hour
proc put:hour { min hour day month year } {
putserv "PRIVMSG #NewsRoom :\0030,4» LIVE \0030,12> Breaking News & Market Action 24/7 \0031,15> http://www.247newsroom.com \00312,12 \003"}

I'd like to add to the message (after the 'LIVE') the current US Eastern time (16 hours behind my local time) and GMT time (12 hours behind my local time).

If anyone could help me with the asctime and calc commands that would be great! Thanks =)
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

this code should help you out..

Code: Select all

proc gettime { offset } {
set hour [clock format [clock seconds] -format "%H"]
set therest [clock format [clock seconds] -format "%M:%S"]
set time_ret [expr $hour + $offset]
if {[expr $time_ret > 23]} { set time_ret [expr $time_ret - 24] }
if {[expr $time_ret < 0]} { set time_ret [expr $time_ret + 24] }
return $time_ret:$therest
}
you can use this with [gettime -16] for US Estern and with [gettime -12] for gmt

i know this can be done in a lower number of lines, but this way its easy to understand for everybody
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

or just add/subtract the number of seconds from [clock seconds] before formatting it :)
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

thanks GOS - so do I just insert [gettime -16] etc into my hourly msg line for it to display...sorry if that's a dumb question!
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

Code: Select all

bind time - "00 * * * *" put:hour 
proc put:hour { min hour day month year } { 
putserv "PRIVMSG #NewsRoom :\0030,4» LIVE ([gettime -16] US Eastern and [gettime -13] GMT) \0030,12> Breaking News & Market Action 24/7 \0031,15> http://www.247newsroom.com \00312,12 \003"
}


you can strip the seconds by removing ":%S" from the gettime proc
and dont forget to load the gettime proc,best is if you add it to the same .tcl as your current script

btw : they way user thought about it :

Code: Select all

proc gettime { offset } {
return [clock format [expr [clock seconds] + [expr $offset] * 60 * 60] -format "%H:%M:%S"]
}
then the date is correct too
Last edited by GodOfSuicide on Fri Sep 05, 2003 6:19 am, edited 1 time in total.
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

cool - thanks for that. will report back when the clock strikes the next hour!
:)
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
N
NewzUK
Master
Posts: 200
Joined: Mon Nov 18, 2002 3:10 am
Location: Auckland, New Zealand
Contact:

Post by NewzUK »

works a treat - thanks very much!
#Newsroom - Where News & Markets Connect
http://www.inewsroom.net
#Newsroom on irc.othernet.org
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

you're welcome
Locked