Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date translation
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00935198
Message ID:
00935300
Vues:
25
>>It could be converted to UTC using something like my Windows Time class in the download section. This way you'd remove any problems with the current bias.
>
>I've been reading several of your posts since this morning to try to find the way to do it based on your high experience in that area. Even after having downloaded your class, I couldn't find a function that would accept that date format string and convert it into a datetime. Could you help me on this?

Michel,

There's no simple way to do this. However, this is what I'd do. First, strip out the character day of the week
ltdt = 'Thu, 20 May 2004 08:50:03 PDT'
ltdt = ALLTRIM(SUBSTR(ltdt, AT(',', ltdt) + 1))
Next, I'd insert the month number, which I'd get from a look-up table
LOCATE FOR LEFT(lddt, 3) = monthname
ltdt = STUFF(ltdt, 4, 3, monthnum)
Then I'd replace the spaces with a slash.
ltdt = STUFF(ltdt, AT(SPACE(1), ltdt), 1, '/')
ltdt = STUFF(ltdt, AT(SPACE(1), ltdt), 1, '/')
Next, I set the date format.
lcdateformat = SET('DATE')
SET DATE TO DMY
Then translate it to a date/time
lcdt = ltdt
ltdt = CTOT(LEFT(ltdt, LEN(ltdt) - 4))
SET DATE (lcdateformat)
Finally, I'd use a lookup table with the last 3 characters of the string. The table would have a structure containing the 3 characters of the timezone (for example: PST, PDT, EST, EDT, etc.) and the bias between it and your timezone. It would probably be a good idea to express this in seconds so that you could simply add it to the date/time you've got. If the bias is negative, adding it would produce the correct result.
LOCATE FOR RIGHT(lcdt, 3) = timezone.timezone
ltdt = ltdt + timezone.bias
George

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

Click here to load this message in the networking platform