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.

Time Help

Help for those learning Tcl or writing their own scripts.
Post Reply
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Time Help

Post by Ace-T »

set math [expr [clock seconds] - $typl]
putlog "$math"

or

set math [expr [unixtime] - $typl]
putlog "$math"


what would be better is

set maxtime 300
if {[expr [unixtime]-[clock scan $typl]]>=$maxtime} {
putlog "$maxtime"

but that wont even work =/


i tried putting the put log in for some de bugging and it wouldnt return anything :(

i have no idea why

time is stored in the db as: 2007-05-03 12:35:25
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Do you think you could atleast try to explain what you try to achieve, and how your results differ from that?
Also, what would "typl" typically be? What could it be?
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

ok found my problem

its cause the times not stored in unix time stamp so i need to get it into that now..

but cant seem to do it :(

here is my query

set sql "INSERT INTO test VALUES(null, 'TEST', '$text1', '$type', unix_timestamp(now))"

but wont work >_>
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Right now I can't make heads and tails about what it is you are asking help with... You're just posting fragments that really does'nt make much sense by their own...

If you are asking for help on constructing a valid sql-query, we'd need help on which dialect of sql you're using (mysql, postgresql, mssql, etc), the actual layout of your database and so forth...

What I can say, atleast for mysql, is that it is advisable to supply a column-list with INSERT-queries (although not required).

http://dev.mysql.com/doc/refman/4.1/en/index.html might also be worth a visit.
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

to be all honest all i want is something like thsi working

set maxtime 300
if {[expr [unixtime]-[clock scan $typl]]>=$maxtime} {
putlog "$maxtime"

my time in sql is not in unix time stamps so the code is useless atm,
$typl is just a table i made to store the date time ( like 00-00-00 00:00:00)

i basically need the code to only say some text in irc if the time is under 300 secs, ive been searching the forums for hours for an answer.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

If you just want something to work, you'd be better off posting under "Script Requests".

$typl is not a table.. it's a variable.. If the value is retrieved from a sql-database using a query, say so.

That said, most time/date formats used by various sql-dialects can be directly interpreted using "clock scan". The date in your first post works just fine with "clock scan" (tested with: clock format [clock scan "2007-05-03 12:35:25"]). If you are using some different date/time-format, please specify it.'

Also, you say it should respond if the time delta is less than 300, yet your test in the conditional is wether it is actually greater or equal than 300...
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

right,

time is stored in the db as: 2007-05-03 12:35:25

i want the code to react to if under 300 secs

and im sure this line does NOT work due to my time not being stored as unixtime, code here -> if {[expr [unixtime]-[clock scan $typl]]<=$maxtime} {


also
$typl is not a table.. it's a variable.. If the value is retrieved from a sql-database using a query, say so.
yeh i didnt read back what wrote just stressed cause i cant seem to fix this :(
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Then why don't you re-read the last line in my previous post...

Code: Select all

expr [unixtime]-[clock scan "2007-05-03 12:35:25"]
returned a value of 732398 for me, which is quite larger than 300, and hence the conditional would be true, and whatever code you have within your if-statement would be executed.
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

set maxtime 3000000000000000000000
if {[expr [unixtime]-[clock scan $typl]]<=$maxtime} {

putquick "PRIVMSG $channel : TEST -> WORKING"
return 0
}


just tried that and it dont work, so im lost.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Try setting maxtime to something alittle smaller, that won't overflow. Such as 2000000...
In any case, have you tried printing the actual value that you're comparing: ie putlog "$typl : [expr [unixtime] - [clock scan $typl]]", so that you can see what is actually going on?
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

nothing at all in logs =/
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Then, without knowing the contents of your script, there's not much else I can do...
NML_375
A
Ace-T
Halfop
Posts: 82
Joined: Tue Aug 29, 2006 7:25 am

Post by Ace-T »

i would like to say thx for the guidance :)

i have completed my mission and have it fully working now :)
Post Reply