ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Récupérer des informations régionales de date (décalage horaire par exemple)   



L'auteur

Francis Faure
France France
Membre Actif (personne physique)
# 0000000001
enregistré le 11/10/2004

http://www.wanagain.net
56 ans
Faure Francis
de la société Design Or Decline
Fiche personnelle


Note des membres
pas de note

Contributions > 05 - API et appels systèmes

Récupérer des informations régionales de date (décalage horaire par exemple)
# 0000000514
ajouté le 19/03/2008 19:44:50 et modifié le 19/03/2008
consulté 7068 fois
Niveau débutant

Description

Après avoir travaillé au moyen de l'article de Frédéric :

http://www.atoutfox.org/articles.asp?ACTION=FCONSULTER&ID=0000000476

Sur :  GetTimeZoneInformation
j'ai réalisé une fonction similaire, mais sous une autre écriture.

Code source :
? GetEcartGMT()

* 19 Mars 2008 : GetTimeZoneInformation
* http://msdn2.microsoft.com/en-us/library/ms724421(VS.85).aspx
* Merci Fédéric
*typedef struct _TIME_ZONE_INFORMATION { // tzi
*    LONG       Bias;          4
*    WCHAR      StandardName[ 32 ];    64 (unicode sinon 32)
*    SYSTEMTIME StandardDate;      SizeOfSystemTime 16
*    LONG       StandardBias;      4
*    WCHAR      DaylightName[ 32 ];    64 (unicode sinon 32)
*    SYSTEMTIME DaylightDate;      SizeOfSystemTime 16
*    LONG       DaylightBias;      4
*} TIME_ZONE_INFORMATION

  #DEFINE TIME_ZONE_ID_UNKNOWN 0
  #DEFINE TIME_ZONE_ID_STANDARD 1
  #DEFINE TIME_ZONE_ID_DAYLIGHT 2

  FUNCTION GetEcartGMT as String
    LOCAL lcReturn as String
    LOCAL liRetCode as Integer, TZInfo  as String, liEcartGMT as Integer
    LOCAL liHours as Integer, liMinutes as Integer
    TZInfo = SPACE(172)
    DECLARE INTEGER GetTimeZoneInformation IN kernel32 STRING @TZInfo
    liRetCode = GetTimeZoneInformation(@TZInfo)
    CLEAR DLLS GetTimeZoneInformation
    DO case
       CASE m.liRetCode=TIME_ZONE_ID_UNKNOWN OR m.liRetCode=TIME_ZONE_ID_STANDARD
         liEcartGMT = -buf2dword(SUBSTR(m.TZInfo, 1, 4))
       CASE m.liRetCode = TIME_ZONE_ID_DAYLIGHT
         liEcartGMT = -(buf2dword(SUBSTR(m.TZInfo, 1, 4)) + buf2dword(SUBSTR(m.TZInfo, 169, 4)))
    ENDCASE
    lcReturn = IIF(m.liEcartGMT>=0, "+","-")
    liHours = INT(ABS(m.liEcartGMT)/60)
    liMinutes = ABS(m.liEcartGMT) - 60*m.lihours
    lcReturn = lcReturn + PADL(ALLTRIM(STR(m.liHours)),2,"0") + PADL(ALLTRIM(STR(m.liMinutes)),2,"0")
  RETURN lcReturn

  FUNCTION buf2dword(lcBuffer)
  RETURN Asc(SUBSTR(m.lcBuffer, 1,1)) + ;
        BitLShift(Asc(SUBSTR(m.lcBuffer, 2,1)), 8) +;
        BitLShift(Asc(SUBSTR(m.lcBuffer, 3,1)), 16) +;
        BitLShift(Asc(SUBSTR(m.lcBuffer, 4,1)), 24)

Commentaires
Aucun commentaire enregistré ...

Publicité

Les pubs en cours :


www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3