Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local time and System time
Message
 
À
17/12/1999 17:01:13
Alex Zhadanov
Computer Generated Solutions
New York City, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00305457
Message ID:
00305710
Vues:
19
Alex,

This is another addendum to what I wrote earlier.

Unfortunately, the routine I supplied is not 100% accurate. It is 99.98% accurate, however. Here's the problem.

One hour, each year, occurs twice. This is during the period of transition from Daylight Savings Time to Standard Time. For example, 1:01 AM occurred twice on October 31 this year. It happened once during Daylight Savings and once during Standard Time.

It's easy to think that you can simply compare the biases as returned by a call to GetTimeZoneInformation. Unfortunately, this doesn't work.

My original post deals with any date/time, including those which have past. As I've mentioned, it's only 99.988% effective.

You can, however, record the current date/time without this concern. The following snippet adjusts the date/time value to UTC time, and takes into account the problem described above.
FUNCTION CurrentUTC
LOCAL ltdatetime, lctimezone
ltdatetime = DATETIME()
SET PROCEDURE TO CON_INT ADDITIVE
oInteger = CREATEOBJECT("ConvertInt")
RELEASE PROCEDURE CON_INT
DECLARE INTEGER GetTimeZoneInformation IN Win32API;
  STRING @lpTimeZoneInformation
lctimezone = REPLICATE(CHR(0), 172)
= GetTimeZoneInformation(@lctimezone)
ltdatetime = ltdatetime + (oInteger.StringToInteger(LEFT(lctimezone, 4), .T.) * 60)
RETURN ltdatetime
The above adjusts the date/time based on the current (when the function is called) bias.
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform