Code : Tout sélectionner
Procedure.s rfcToLocal(rfcDate.s)
;/
;/ 'RFC Date String' --> 'Local Date String'
;/
;/ in: STRING rfcDate ex. "Wed, 03 Sep 2003 13:21:05 +0100"
;/ out: STRING localDate ex. "Wednesday, 3 September 2003 13:21:05"
;/
;/ RFC STRING --> SYSTEMTIME
libID.l = OpenLibrary(#PB_Any,"wininet.dll")
If libID
CallFunction(libID,"InternetTimeToSystemTime",rfcDate,SystemDate.SYSTEMTIME,0)
CloseLibrary(libID)
Else
ProcedureReturn ""
EndIf
;/ SYSTEMTIME --> LOCAL DATE STRING
DateFormat.s = "dddd',' d MMMM yyyy gg"
nBytes.l = GetDateFormat_(0,0,SystemDate,DateFormat,"",0)
LocalDate.s = Space(nBytes)
If GetDateFormat_(0,0,SystemDate,DateFormat,LocalDate,nBytes) = 0
ProcedureReturn ""
EndIf
;/ SYSTEMTIME --> LOCAL TIME STRING
TimeFormat.s = " HH':'mm':'ss"
nBytes.l = GetTimeFormat_(0,#TIME_FORCE24HOURFORMAT,SystemDate,TimeFormat,"",0)
LocalTime.s = Space(nBytes)
If GetTimeFormat_(0,#TIME_FORCE24HOURFORMAT,SystemDate,TimeFormat,LocalTime,nBytes) = 0
ProcedureReturn LocalDate
EndIf
;/ RFC 'GMT PART' STRING --> CORRECTED LOCAL TIME STRING
GMT.s = StringField(rfcDate,6," ")
Debug GMT ; ?
ProcedureReturn LocalDate + LocalTime
EndProcedure
Debug rfcToLocal("Wed, 03 Sep 2003 13:21:05 -0400")
ceci dit je ne sais pas comment gérer la correction GMT...
si qq pourrait m'aider à améliorer cette fonction...
