>>I have this format that I need to translate into a DateTime format:
>>
>>
>>Thu, 20 May 2004 08:50:03 PDT
>>
>>
>>Is there a simple way to have that into my own time zone properly formatted?
>
>Michel -
>are the spaces always there between each date element?
>if so -
>you should be able to parse it with at() and substr()
>do you care about the name of the day? if not, you can skip that.
>after 'getting it all' you will still need to add time for your zone.
>
>i feel [ug] it could be done in 20 lines or less.
>
>regards [Bill]
I do not have the time zone conversion incorporated - if it is always from PDT to Michel's then that should be easy. If any time zone needs to be considered then a lookup will be required - and this could be done the same way as the month lookup. You were correct about the solution being less than 20 lines. Here is a one line conversion:
cDateToConvert = "Thu, 20 May 2004 08:50:03 PDT"
iZoneConversion = -2
tConverted = DATETIME( VAL( SUBSTR( cDateToConvert, AT( " ", cDateToConvert, 3 ) + 1 )) ;
, (AT( SUBSTR( cDateToConvert, 9, AT( " ", cDateToConvert, 3) -9 ) ;
, "January " ;
+ "February " ;
+ "March " ;
+ "April " ;
+ "May " ;
+ "June " ;
+ "July " ;
+ "August " ;
+ "September" ;
+ "October " ;
+ "November " ;
+ "December " ) +8 ) / 9 ;
, VAL( SUBSTR( cDateToConvert, 6)) ;
, VAL( SUBSTR( cDateToConvert, AT( " ", cDateToConvert, 4 ) + 1 )) + iZoneConversion ;
, VAL( SUBSTR( cDateToConvert, AT( " ", cDateToConvert, 4 ) + 4 )) ;
, VAL( SUBSTR( cDateToConvert, AT( " ", cDateToConvert, 4 ) + 7 )))
? tConverted
censored.