Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to get timezone bias
Message
 
À
11/11/2003 22:18:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00848960
Message ID:
00848971
Vues:
16
< update >
In fact, Rick's function returns -660 -- it must be the bias to get back to GMT, not the bias from GMT.

Cheers,

Andrew
< /update >
Hi Doug,

Don't know if you have access to Rick Strahl's stuff, but there's a frunction in wwAPI called GetTimeZone that returns the offset in minutes from GMT (which should be +660 from my POV -- we're GMT+11 hours at the moment I think you might have travelled the wrong way around the world to get to your -780)

Cheers,

Andrew

>Hi,
>
>I have obtained some code from FoxWiki to get the timezone bias from my system, but the returned bias is incorrect. I live in Melbourne Australia and currently we have daylight savings.
>The bias is supposed to be returned in minutes, I guess from GMT. If this is the case, then -780 should be returned, however it is returning -7116, which doesn't even equate to seconds. here's the code I am using...
>
>
>
>lnBias = GetTimeZone('BIAS') && In Util.prg
>lcBias = iif( lnBias<0, '+', '-' )
>lnBias = abs(lnBias)
>lcBias = lcBias+PadL(Tran(lnBias/60),2,'0')+PadL(Tran(lnBias%60),2,'0')
>lcRet = LEFT( CDOW(ltDT), 3 )+', '+Str( Day(ltDt), 2 ) + ' ' + LEFT( CMONTH(ltDT), 3);
>            +' '+TRAN( Year(ltDT) )+' '+PadL(Tran(hour(ltDT)),2,'0')+':';
>            +PadL(Tran(Minute(ltDT)),2,'0')+':';
>            +PadL(Tran(Sec(ltDT)),2,'0')+' ';
>            +lcBias
>RETURN
>
>
>FUNCTION GetTimeZone( pcFunc )
>* Purpose: Return the Time Zone bias or description
>* Input: pcFunc = "BIAS" or Missing... return the bias in Minutes
>* ( GMT = LocalTime? + Bias )
>* pcFunc = "NAME" ... Return the time zone name.
>* Author: William GC Steinford
>***********************************************************
>LOCAL lcTZInfo, lcDesc
>lcTZInfo = num2dword(0);
>           +repl(chr(0),64)+repl(num2Word(0),8)+num2dword(0);
>           +repl(chr(0),64)+repl(num2Word(0),8)+num2dword(0)
>DECLARE INTEGER GetTimeZoneInformation IN kernel32.dll;
>    STRING @ lpTimeZoneInformation
>#DEFINE TIME_ZONE_ID_INVALID 0xFFFFFFFF
>#DEFINE TIME_ZONE_ID_UNKNOWN 0
>#DEFINE TIME_ZONE_ID_STANDARD 1
>#DEFINE TIME_ZONE_ID_DAYLIGHT 2
>lcRes = GetTimeZoneInformation( @lcTZInfo )
>lnBias = Buf2DWord( lcTZInfo )
>lcDesc = "Unknown"
>do case
>  case lcRes=TIME_ZONE_ID_STANDARD
>    lcDesc = substr( lcTZInfo, 3, 64 )
>    lcDesc = StrConv( lcDesc, 6 ) && 6=Unicode(wide)->DoubleByte
>    lcDesc = strTran( lcDesc, chr(0), '' )
>  case lcRes=TIME_ZONE_ID_DAYLIGHT
>    lcDesc = substr( lcTZInfo, 3, 64 )
>    lcDesc = StrConv( lcDesc, 6 )
>    lcDesc = strTran( lcDesc, chr(0), '' )
>endcase
>if varType(pcFunc)='C' and pcFunc='NAME'
>  RETURN lcDesc
>endif
>RETURN lnBias
>ENDFUNC
>
>FUNCTION buf2dword(lcBuffer)
>RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
>       Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
>       Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
>       Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
>ENDFUNC
>
>
>I hope someone has solved this problem previously.
>
>Regards
>Doug Johnston


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform