LoginLogin

Time seconds function thing

Root / Submissions / [.]

12Me21Created:
Prokuku wanted me to make a page for this....
'Calculate number of seconds since 2000
DEF TIME()
 VAR H,M,S
 VAR Y,MO,D
 TMREAD OUT H,M,S
 DTREAD OUT Y,MO,D
 DEC D
 DEC MO
 INC S,M*60
 INC S,H*60*60
 VAR I
 FOR I=2000 TO Y-1
  INC S,(365+ISLEAPYEAR(I))*60*60*24
 NEXT
 INC S,DAYSINMONTH(Y,MO,D)*60*60*24
 RETURN S
END

DEF ISLEAPYEAR(Y)
 RETURN Y MOD 4==0 && (Y MOD 100!=0 || Y MOD 400==0)
END

'get days in a month (aaaaaaa)
DEF DAYSINMONTH(Y,M,D)
 IF M==0 THEN RETURN D
 INC D,31
 IF M==1 THEN RETURN D
 INC D,28+ISLEAPYEAR(Y)
 IF M==2 THEN RETURN D
 INC D,31
 IF M==3 THEN RETURN D
 INC D,30
 IF M==4 THEN RETURN D
 INC D,31
 IF M==5 THEN RETURN D
 INC D,30
 IF M==6 THEN RETURN D
 INC D,31
 IF M==7 THEN RETURN D
 INC D,31
 IF M==8 THEN RETURN D
 INC D,30
 IF M==9 THEN RETURN D
 INC D,31
 IF M==10 THEN RETURN D
 INC D,30
 IF M==11 THEN RETURN D
END

👍