
Mhmh... C'est juste qu'il y a un nirvana possible dans la réflexionDobro a écrit :ben tu connais pas ma copine alors
Mhmh... C'est juste qu'il y a un nirvana possible dans la réflexionDobro a écrit :ben tu connais pas ma copine alors
Code : Tout sélectionner
DateHeure=chope l'heure sur internet (sur une page à toi) comme ça pas de bidouille possible.
If dateheure<heuredebut OR dateheure>heureFin
if nomdel'exe_qui_lance_le_jeu.exe tourne en process
Alors ferme les ports internet.
endif
endif
Kwai chang caine a écrit :Merci ar-s de ton conseil
C'est une bonne idée d'aller chercher l'heure sur le "terre net"
Remarque y'a peut etre carrement un site qui retourne l'heure, ça doit bien exister puisque tout existe sur le net
Code : Tout sélectionner
;/ Get Time from NTP Server / Set Local Time / Get Time Zone information
; Droopy 15/01/06 + Fweil for TimeZone functions
; PureBasic 4.10
ProcedureDLL.s GetTimeZoneName() ; Return the name of the Time Zone
;/ Author : Fweil
GetTimeZoneInformation_(TimeZoneInfo.TIME_ZONE_INFORMATION)
While TimeZoneInfo\StandardName[i] <>0 And i <= 32
sStandardName.s + Chr(TimeZoneInfo\StandardName[i])
i + 1
Wend
ProcedureReturn sStandardName
EndProcedure
ProcedureDLL GetTimeZone() ; Hour to add to the UTC hour
;/ Author : Fweil
GetTimeZoneInformation_(TimeZoneInfo.TIME_ZONE_INFORMATION)
retour=-TimeZoneInfo\Bias/60
ProcedureReturn retour
EndProcedure
ProcedureDLL SetDate(date) ; Set the System Date : Return 1 if success
Heure.SYSTEMTIME
Heure.SYSTEMTIME\wYear=Year(date)
Heure.SYSTEMTIME\wMonth=Month(date)
Heure.SYSTEMTIME\wDay=Day(date)
Heure.SYSTEMTIME\wDayOfWeek=DayOfWeek(date)
Heure.SYSTEMTIME\wHour=Hour(date)
Heure.SYSTEMTIME\wMinute=Minute(date)
Heure.SYSTEMTIME\wSecond=Second(date)
If SetSystemTime_(Heure)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
ProcedureDLL GetNTPTime(NTPServer.s,TimeOut) ; Ask a NTP Server and return the Date as PureBasic format / 0 if it could not be joined
; Server = time.ien.it / time.nist.gov / ntp1.fau.de
InitNetwork()
CnxionId= OpenNetworkConnection(NTPServer,37)
If CnxionId
;/ Wait until the Server Send Datas
While NetworkClientEvent(CnxionId)=0
Delay(1)
t+1
If t>TimeOut
ProcedureReturn 0
EndIf
Wend
;/ Wait until the Server Send Datas
While NetworkClientEvent(CnxionId)=0
Delay(1)
Wend
;/ Get four Bytes
Buffer.s=Space(4)
ReceiveNetworkData(CnxionId,@Buffer,4)
CloseNetworkConnection(CnxionId)
;/ Calcule the Date as PureBasic Format ( UTC )
NTPTime=Asc(Left(Buffer,1))*16777216 + Asc(Mid(Buffer,2,1))*65536 + Asc(Mid(Buffer,3,1))*256 + Asc(Right(Buffer,1)) - 2840140800
NTPTime=AddDate(NTPTime,#PB_Date_Year,20) ; Add 20 years
ProcedureReturn NTPTime
Else
ProcedureReturn 0
EndIf
EndProcedure
ProcedureDLL GetNTPTime2(NTPServer.s) ; Default TimeOut = 120ms
ProcedureReturn GetNTPTime(NTPServer.s,120)
EndProcedure
;/ Test
NTPTime=GetNTPTime2("time.ien.it")
If NTPTime
;/ Set the Computer Time as NTP Time
SetDate(NTPTime)
;/ Show information about Hour
temp.s="UTC Time : "+FormatDate(" %dd/%mm/%yy %hh:%ii:%ss",NTPTime)+#CR$
temp+"Zone : "+GetTimeZoneName()+#CR$
temp+"Shift : "+Str(GetTimeZone())+" hour(s)"+#CR$
temp+"Local Time as US format : "+FormatDate(" %mm/%dd/%yy %hh:%ii:%ss",NTPTime+GetTimeZone()*60*60)+#CR$
temp+"Local Time as French format : "+FormatDate(" %dd/%mm/%yy %hh:%ii:%ss",NTPTime+GetTimeZone()*60*60)+#CR$
MessageRequester("UTC et NTP",temp)
EndIf
l'heure d'ete est une specificité "europeene" et encore, a londre ils reste a l'heure Solaire !!Ar-S a écrit :Il doit y avoir une tite coquille dans le code car il ne prend pas en compte l'heure d'étéil affiche une heure de moins chez moi.
Giscard a instauré l'heure d'ETE apres le choc pétrolier !!Ollivier a écrit :C'est pas en 1973 plutôt ???