egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calculating time

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
uHost
Voice


Joined: 20 Aug 2009
Posts: 2

PostPosted: Thu Aug 20, 2009 2:29 pm    Post subject: calculating time Reply with quote

Hello. Very Happy

can anyone help with a script?

I need a script calculating time in minutes. For exemple:

18:55 20/08/2009 >> Today

<uHost> !time 10
<Eggie> 19:05 20/08/2009
<uHost> !time 1440
<Eggie> 18:55 21/08/2009

I think you can understand me. Smile
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Aug 20, 2009 2:47 pm    Post subject: Reply with quote

Code:
# tomekk, http://forum.egghelp.org/viewtopic.php?t=17119
bind pub -|- !time make_time

proc make_time { nick uhost hand chan arg } {
   set arg [lindex [split $arg] 0]

   if {[regexp {^[0-9]+$} $arg]} {
      set cdate [clock format [expr [clock seconds] + [expr $arg * 60]] -format "%H:%M %d/%m/%Y"]

      putquick "PRIVMSG $chan :$cdate"
   }
}

putlog "make-time.tcl ver 0.1 by tomekk loaded"


try, didn't test ;p
Back to top
View user's profile Send private message Visit poster's website
uHost
Voice


Joined: 20 Aug 2009
Posts: 2

PostPosted: Thu Aug 20, 2009 4:28 pm    Post subject: Reply with quote

Hehe

It works, but has a bug. I can't use more than 9 numbers.

<uHost> !time 12345678
<Eggie> 06:41 09/02/2033
<uHost> !time 123456789
<Eggie> 05:35 01/03/1972

Thanks Wink
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Thu Aug 20, 2009 4:47 pm    Post subject: Reply with quote

The value of the supplied argument is too high and the result of the expr command has wrapped to a negative integer value. Hence, instead of adding to [clock seconds] which results in a future time string, it has been deducted from [clock seconds] which has given a past time string. It is not so much a bug, more of a limitation.
_________________
I must have had nothing to do
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber