Cette fois, c'est bon !
durée de fonctionnement, heure et jour d'allumage.
merci Maan d'avoir testé.
J.-C.
include "HJConst.jsh"
String Function QuelJour (int iJour)
var string qj, int z, string sDate
sDate = SysGetDate ("dd/MM/yyyy")
qj = GetDayOfWeek (SysGetDate ("yyyy/MM/dd"))
if qj == "dimanche"
z = 0
elif qj == "samedi"
z=1
elif qj == "vendredi"
z=2
elif qj == "jeudi"
z=3
elif qj == "mercredi"
z=4
elif qj == "mardi"
z=5
elif qj == "lundi"
z=6
endif
z = (z + iJour)%7
if z == 0
saystring("dimanche")
elif z == 1
saystring("samedi")
elif z == 2
saystring("vendredi")
elif z == 3
saystring("jeudi")
elif z == 4
saystring("mercredi")
elif z == 5
saystring("mardi")
elif z == 6
saystring("lundi")
endif
EndFunction
String Function ConvertSecondToTime (int iTotal)
var int j, int h, int m, int s
j = iTotal /86400;ça, c'est le nombre de secondes dans un jour
h = (iTotal-j*86400)/3600
m = (iTotal-(j*86400+h*3600))/60
s = (iTotal-(j*86400+h*3600 + m*60))
if j == 0 && h == 0 && m == 0
iTotal = s + " seconde"
elif j == 0 && h == 0 && s == 0
iTotal = m + " minute"
elif j == 0 && m == 0 && s == 0
iTotal = h + " heure "
elif j == 0 && s == 0
iTotal = h + " heure " + m + " minute "
elif j == 0 && h == 0
iTotal = m + " minute " + s + " seconde"
elif j == 0
iTotal = h + " heure " + m + " minute " + s + " seconde"
elif h == 0
iTotal = j + " jour " + m + " minute " + s + " seconde"
elif m == 0
iTotal = j + " jour " + h + " heure " + s + " seconde"
elif s == 0
iTotal = j + " jour " + h + " heure " + m + " minute "
else
iTotal = j + " jour " + h + " heure " + m + " minute " + "et" + s + " seconde"
endif
return iTotal
EndFunction
Int Function ConvertTimeToSecond (string sTemp)
var int nbs, string h, string m, string s
h = StringSegment (sTemp, ":", 1)
m = StringSegment (sTemp, ":", 2)
s = StringSegment (sTemp, ":", 3)
nbs = StringToInt(h)* 3600 + StringToInt(m) * 60 + StringToInt(s)
return nbs
EndFunction
String Function Quand (int jour, int HeureActuelle, int HeureDallumage)
if jour == 0 && HeureActuelle> HeureDallumage
return ("aujourd'hui !")
elif jour == 0 && HeureActuelle < heureDallumage
return ("hier")
elif jour == 1 && HeureActuelle > heureDallumage
return ("hier")
elif jour == 1 && HeureActuelle < heureDallumage
return ("Avan hier")
elif jour == 2 && HeureActuelle > heureDallumage
return("Avant hier")
endif
EndFunction
Script QuelDate ()
;AltCtrlT
var int i, int i2, int hd, string hA, int ihA, int j, string qj ; détermine
quel jour de la semaine
let i = GetTickCount ()/1000 ;
let i2 = i%86400
j = i / 86400
hA = SysGetTime ("HH:mm:ss") ;
ihA = ConvertTimeToSecond(hA)
if IsSameScript ()
delay (1)
saystring("elle a été allumée à")
hd = ihA - i2
if hd < 0 then
hd = hd + ( 86400)
endif
if hd > iHA
let j = j+1
endif
sayString (ConvertSecondToTime (hd))
saystring (Quand (i/86400, ihA, hd))
saystring(QuelJour (j));, iHa))
else
Delay (2)
saystring("cette machine tourne depuis")
SayString(ConvertSecondToTime (i))
endif
EndScript