Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UTC time Conversion
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 2000 SP3
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01572478
Message ID:
01572733
Vues:
67
>Opps....... chartobin function?? What do I do?
************************************************************************
FUNCTION CharToBin(lcBinString,llSigned)
****************************************
***  Function: Binary Numeric conversion routine. 
***            Converts DWORD or Unsigned Integer string
***            to Fox numeric integer value.
***      Pass: lcBinString -  String that contains the binary data 
***            llSigned    -  if .T. uses signed conversion
***                           otherwise value is unsigned (DWORD)
***    Return: Fox number
************************************************************************
LOCAL m.i, lnWord

lnWord = 0
FOR m.i = 1 TO LEN(lcBinString)
 lnWord = lnWord + (ASC(SUBSTR(lcBinString, m.i, 1)) * (2 ^ (8 * (m.i - 1))))
ENDFOR

IF llSigned AND lnWord > 0x80000000
  lnWord = lnWord - 1 - 0xFFFFFFFF
ENDIF

RETURN lnWord
*  wwAPI :: CharToBin
+++ Rick ---

>
>Thanks
>
>>This is what I use:
>>
>>
>>************************************************************************
>>FUNCTION GetTimeZone
>>*********************************
>>***  Function: Returns the TimeZone offset from GMT including
>>***            daylight savings. Result is returned in minutes.
>>************************************************************************
>>
>>PUBLIC __TimeZone
>>IF VARTYPE(__TimeZone) = "N"
>>   RETURN __TimeZone
>>ENDIF
>>
>>DECLARE integer GetTimeZoneInformation IN Win32API ;
>>   STRING @ TimeZoneStruct
>>   
>>lcTZ = SPACE(256)
>>
>>lnDayLightSavings = GetTimeZoneInformation(@lcTZ)
>>
>>lnOffset = CharToBin(SUBSTR(lcTZ,1,4),.T.)
>>
>>*** Subtract an hour if daylight savings is active
>>IF lnDaylightSavings = 2
>>   lnOffset = lnOffset - 60
>>ENDIF
>>
>>__TimeZone = lnOffset
>>	
>>RETURN lnOffSet
>>
>>
>>************************************************************************
>>*  GetUtcTime
>>****************************************
>>***  Function: Returns UTC time from local time
>>***    Assume:
>>***      Pass:
>>***    Return:
>>************************************************************************
>>FUNCTION GetUtcTime(ltTime)
>>IF EMPTY(ltTime)
>>   ltTime = DATETIME()
>>ENDIF
>>   
>>RETURN ltTime + (GetTimeZone() * 60)
>>ENDFUNC
>>*   GetUtcTime
>>
>>************************************************************************
>>*  FromUtcTime
>>****************************************
>>***  Function: Returns local time from UTC Time
>>***    Assume:
>>***      Pass:
>>***    Return:
>>************************************************************************
>>FUNCTION FromUtcTime(ltTime)
>>RETURN ltTime - (GetTimeZone() * 60)
>>ENDFUNC
>>*   FromUtcTime
>>
>>
>>
>>+++ Rick ---
>>
>>>Hey Gang!
>>>
>>>Do you have any VFP code that can convert a DATETIME or DATE value into the
>>>
>>>UTC time (given the setup info in Windows itself for the workstation) ??
>>>
>>>Thanks!!
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform