I think this is posted a long time ago on the d3www/mvwww sourceforge site
as well. Hack it up and mangle it all you want. This is to convert current
time into GMT and pass the ISO zone difference as a standalone var. For your
need, you'll have to reverse engineer it. This was written on D3, but it
should be vanilla code.

      SUBROUTINE GMT(GMT,ISOZONEDIFF)
      !
      ! CONVERT CURRENT ZONE TIME TO GMT
      ! DAYLIGHT SAVINGS FOR NORTH AMERICA ONLY
      !
      ! ATL = 4 HOUR DIFFERENCE
      ! EST = 5 HOUR DIFFERENCE
      ! EDT = 4 HOUR DIFFERENCE
      ! CST = 6 HOUR DIFFERENCE
      ! CDT = 5 HOUR DIFFERENCE
      ! MST = 7 HOUR DIFFERENCE
      ! MDT = 6 HOUR DIFFERENCE
      ! PST = 8 HOUR DIFFERENCE
      ! PDT = 7 HOUR DIFFERENCE
      ! ALA = 9 HOUR DIFFERENCE
      ! HAW = 10 HOUR DIFFERENCE
      !
      ATL = "-04:00"
      ATLDIFF=4
      EST = "-05:00"
      ESTDIFF=5
      EDT = "-04:00"
      EDTDIFF=4
      CST = "-06:00"
      CSTDIFF=6
      CDT = "-05:00"
      CDTDIFF=5
      MST = "-07:00"
      MSTDIFF=7
      MDT = "-06:00"
      MDTDIFF=6
      PST = "-08:00"
      PSTDIFF=8
      PDT = "-07:00"
      PDTDIFF=7
      ALA = "-09:00"
      ALADIFF=9
      HAW = "-10:00"
      HAWDIFF=10
      !
      ! CHANGE THE FOLLOWING TWO NUMBERS TO REFERENCE YOUR HOURLY DIFFERENCE
      !
      ! DAYLIGHTSAVINGS (DST) VARIABLES CAN BE SET TO NULL, IF YOU SET THE
      ! DAYLIGHTSAVINGS FLAG TO ZERO. THIS SHOULD ONLY BE DONE FOR ZONES
      ! THAT DO NOT UTILIZE DST.
      !
      DAYLIGHTSAVINGS=1
      MYZONE=EST
      MYDSTZONE=EDT
      MYDIFF=ESTDIFF
      MYDSTDIFF=EDTDIFF
      !
      LOCALTIME = TIME()
      GMT=''
      YR=OCONV(DATE(),'DY')
      ! FIGURE OUT THE EXACT START AND END DATES FOR DAYLIGHT SAVINGS TIME
      ! FOR THIS YEAR
      !
      !#NORTH AMERICAN DST STARTS ON THE FIRST SUNDAY OF APRIL AND ENDS ON
      !#THE LAST SUNDAY OF OCTOBER.
      !
      !NORTH AMERICAN DST CHANGED TO SECOND SUNDAY IN MARCH -> FIRST SUNDAY
IN NOVEMBER
      ! AS OF 02/2007
      !
      IF DAYLIGHTSAVINGS=1 THEN
         TDT="03/01/":YR
         ITDT=ICONV(TDT,'D4/')
         TDTE="11/01/":YR
         IDTE=ICONV(TDTE,'D4/')
         SUNDAYS = 0
         FOR X = 1 TO 31
            DOW=OCONV(ITDT,'DW')
            MON=OCONV(ITDT,'DMA')
            IF MON # "March" THEN GO 100
            IF DOW = 7 THEN
               SUNDAYS = SUNDAYS + 1
            END
            IF SUNDAYS = 2 THEN
               SDAY = X
            END
            ITDT=ITDT+1
         NEXT X
100      
         FOR X = 1 TO 31
            DOW=OCONV(IDTE,'DW')
            MON=OCONV(IDTE,'DMA')
            IF DOW = 7 THEN
               EDAY = X
            END
            IF MON # "November" THEN GO 200
            IDTE=IDTE+1
         NEXT X
200      
         EDTSTART = "04/":SDAY:"/":YR
         EDTSTART = ICONV(EDTSTART,'D4/')
         EDTEND = "10/":EDAY:"/":YR
         EDTEND = ICONV(EDTEND,'D4/')
         IF DATE() >= EDTSTART AND DATE() <= EDTEND THEN
            LOCALTIME=TIME()
            GMT=LOCALTIME+(60*60*MYDSTDIFF)
            ISOZONEDIFF=MYDSTZONE
         END ELSE
            LOCALTIME=TIME()
            ISOZONEDIFF = MYZONE
            GMT=LOCALTIME+(60*60*MYDIFF)
         END
      END
      !
      ! NO DAYLIGHT SAVINGS
      !
      IF DAYLIGHTSAVINGS = 0 THEN
         LOCALTIME=TIME()
         GMT=LOCALTIME+(60*60*MYDIFF) 
         ISOZONEDIFF=MYZONE
      END
      RETURN

-------------------------------------------
Glen Batchelor
IT Director
All-Spec Industries
phone: (910) 332-0424
fax: (910) 763-5664
e-mail: [EMAIL PROTECTED]
-------------------------------------------
www.allspec.com
-------------------------------------------

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:owner-u2-
> [EMAIL PROTECTED] On Behalf Of Raymond DeGennaro II
> Sent: Friday, February 23, 2007 10:49 AM
> To: [email protected]
> Subject: Re: [U2] UD: Best way to convert GMT date/times to internal?
> 
> >It seems to me that you've left out a great deal of what you are
> >trying to get.
> 
> Sorry, I'm looking to convert a GMT date/time group that is DST-less
> and in Zulu-time to the local date/time (several timezones east and
> potentially shifted another hour by DST).  The data is coming from a
> service provider and we have no control over the format.  The data is
> sent as ISO8601 DTG's like:  YYYY-MM-DDThh:mm:ss-00:00 (The time zone
> offset is always 00:00) and a minimal character format:
> YYYYMMDDHHMMSS, depending whether the transaction is being passed
> real-time or as part of a batch mode data file.  The sub-string
> access is easy, it's the timezone/DST translation that I'm looking to
> do "The Right Way".
> 
> At 12:13 +1100 2007/02/23, Boydell, Stuart wrote:
> >To answer to your question - storing the date/time as unix epoch
> >((milli)seconds from 1970-01-01T00:00Z) is probably the most
> >convenient method of storing a pure timestamp, Combine that with
> >locality information of an event and you can re-infer the local time
> >the event occurred.
> 
> The original data is archived, it's just that for integration with
> the existing dataset, and reporting purposes, the date/time needs to
> be converted into internal format in local time.
> 
> So, in the case for one customer, if the timestamp received is 1am
> "today" it would actually need to be stored as 7am "yesterday" (up
> until DST kicks in) or 8am "yesterday" (after DST kicks in).
> 
> Ray
> 
> --
> .=====================================================================.
> | =-=-=-=-=-=-=-= Eagle Rock Information Systems Corp =-=-=-=-=-=-=-= |
> | -=-=-=-=-=-=-=- web and database business solutions -=-=-=-=-=-=-=- |
> | <http://www.eriscorp.com>                <mailto:[EMAIL PROTECTED]> |
> |Midwest Regional Office: 626-535-9658x216 (voice) 626-628-3229 (eFax)|
> .=====================================================================.
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to