mIRC Home    About    Download    Register    News    Help

Print Thread
$time conversion #2979 22/12/02 06:39 AM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
how would you take $time and calc it into seconds ?
for instance $calc($time($ticks))
that returns 12
what i want is how many seconds have passed since 00:00:00 so if it is 10:30 am it would be 37800
then if possible i would like to subtract the amount from 86400 and set that amount as a variable
thx in advance smile


also as a helpful note ? when you post answers etc. i see how some ppl have the code inside two lines ? is that part of the ubb code ?

Re: $time conversion #2980 22/12/02 09:05 AM
Joined: Dec 2002
Posts: 208
C
Cobra Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
there are many ways that this can be acomplished

you can format $time() to return however u like.

so say we take $time(H) to return the current hour in 24hr mode .. * 60 to convert that to minits ..

now .. we add $time(n) which returns the current minits in the current hour .. so now we know how many total minits have past since 0:00:00 .. 60 seconds in a minit .. * 60 to return seconds, now add $time(s) which is the current seconds..

$calc(($time(H) * 60 + $time(n)) * 60 + $time(s))

anouther way would be to use $ctime() to get the ctime value of the current date at 00:00:00 .. and subtract that from the current ctime value (notice ctime is the numbe rof seconds past since jan 01 1970)

$calc($ctime - $ctime($time(mmm dd yyyy 00:00:00)))

$time(mmm dd yyyy 00:00:00) will return the current date, but set the time to 00:00:00, $ctime() of that value is the number of seconds that have past since jan 01 1970 00:00:00 to that time. so we subtract the current $ctime from that value and we get how many seconds have past since today at 00:00:00 to present

hope this was helpful.. there are a few other ways it could be done .. but i'd say these are probly the easiest ..

Cobra^

Re: $time conversion #2981 22/12/02 05:50 PM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
thx Cobra that should work out fine smile

Re: $time conversion #2982 22/12/02 10:41 PM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
ok i have one more Question this is what i am working with
Code:
  
alias xmas {
  set %xmas $duration($calc($ctime(25/12/02) - $ctime))  
  set %xmas1 $calc(($time(H) * 60 + $time(n)) * 60 + $time(s))
  if ( $date == 24/12/2002 ) { goto next }
  :next
  if (%xmas1 > 81000 ) {
    set %xmas2 $calc( 86400 - %xmas1 )
    .timerxmas off    
    .timer 1 %xmas2 amsg 00,04 Merry Christmas!!!  
  }
  else {    
    amsg 00,04 %xmas Until Christmas!     
    .timerxmas 1 3600 xmas  
  }
}
 


my Question is does that look right ? i have had a few problems with if elseif else after :next or similar
sometimes elseif wont work it has to be if etc ? so just a proof read if you dont mind smile thx

Re: $time conversion #2983 22/12/02 11:41 PM
Joined: Dec 2002
Posts: 208
C
Cobra Offline
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 208
ok lets try to do this without totaly re writeing your code hehe

cause i'd do it totaly different. but each person does things there own way

first off

if ( $date == 24/12/2002 ) { goto next }

that line there servs no purpos.. your saying if that is true go to :next which is the next line, but if its not true, it goes there anyways

instead maybe u want
if ( $date == 24/12/2002 ) {

and add a } below where the code ends

that way that code will run when that condition is true.. and just ditch the :next .. but i didnt read the logistics of your code to see how its suposed to flow i'm just asuming ..

Cobra^

Re: $time conversion #2984 22/12/02 11:55 PM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
thats correct if the if $date doesnt = 24/12/2002 i want it to go to
else {
amsg 00,04 %xmas Until Christmas!
.timerxmas 1 3600 xmas

but i think i see where your going just use a && instead of :next ?