Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #6966

Re: GetTimeZoneDiff() documentation missing

From "Karl-Heinz" <invalid@invalid.invalid>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: GetTimeZoneDiff() documentation missing
Date 2014-06-16 14:45 +0200
Message-ID <c0878rFnl71U1@mid.individual.net> (permalink)
References <lnda6q$fp4$1@speranza.aioe.org> <1402661063_1@vo.lu> <lnf96h$6bi$1@speranza.aioe.org> <c05vreF9ba0U1@mid.individual.net> <lnlhd9$p34$1@speranza.aioe.org>

Show all headers | View raw


Hi Jamal,

> I am not using those functions. Any samples on their use would be great.
>
> I was able in getting the the UTC date and time of from the Epoch time.
> The issue right now the local time based on different time zone.

a few months ago we had an unix alert ;-), so i spent some hours in the
sources below. Because the alert went away almost as fast as it raised
further investigations were canceled. But i have the feeling that the
sources must be pretty close ...

There are two DLL imports and two self explaining main functions. Each func
has one optional Parameter "lUTCGMT". Here you can decide if the result will
be either localtime or UTC/GMT.

Let me know how it goes.

regards
Karl-Heinz


---- start ----

_DLL FUNCTION  SystemTimeToTzSpecificLocalTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpUniversalTime AS _WINSYSTEMTIME , lpLocalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.SystemTimeToTzSpecificLocalTime

_DLL FUNCTION  TzSpecificLocalTimeToSystemTime ( lpTimeZoneInformation AS
_WINTIME_ZONE_INFORMATION , lpLocalTime AS _WINSYSTEMTIME ,lpUniversalTime
AS _WINSYSTEMTIME ) AS LOGIC PASCAL:Kernel32.TzSpecificLocalTimeToSystemTime

FUNCTION WinDateTime2UnixDateTime ( d AS DATE , nHours AS INT , nMinutes AS
INT , nSeconds AS INT , lUTCGMT := FALSE AS LOGIC ) AS INT PASCAL
LOCAL nUnixDateTimestamp, nDays AS INT
LOCAL s1, s2 AS _WINSYSTEMTIME


   nUnixDateTimestamp := -1



   // -------------------------

   nDays := INT ( _CAST , d ) - INT ( _CAST , ConDate ( 1970 , 1 , 1 ) )



   IF lUTCGMT

     nUnixDateTimestamp := ( nDays * 86400 ) + ( nHours * 3600 ) + (
nMinutes * 60 ) + nSeconds


   ELSE

  s1 := MemAlloc ( _SIZEOF (  _WINSYSTEMTIME ) )
  s2 := MemAlloc ( _SIZEOF (  _WINSYSTEMTIME ) )


    s1.wYear := Year ( d )
    s1.wMonth := Month ( d )
    s1.wDay :=  Day ( d )
    s1.wHour := nHours
    s1.wMinute := nMinutes
    s1.wSecond := nSeconds


    IF TzSpecificLocalTimeToSystemTime ( NULL , s1 , s2 )

   nUnixDateTimestamp := ( nDays * 86400 ) + ( s2.wHour * 3600 ) + (
s2.wMinute * 60 ) + s2.wSecond

    ENDIF

    MemFree ( s1 )
   MemFree ( s2 )


   ENDIF


 RETURN nUnixDateTimestamp

FUNCTION UnixDateTime2WinDateTime ( nUnixDateTimestamp AS INT , d REF DATE ,
nHours REF INT , nMinutes REF INT , nSeconds REF INT , lUTCGMT := FALSE AS
LOGIC  ) AS LOGIC PASCAL
LOCAL nDays, nSecondsRest1, nSecondsRest2, nSecondsRest3 , nHoursTemp,
nMinutesTemp, nSecondsTemp AS INT
LOCAL dWinDate AS DATE
LOCAL s1, s2 AS _WINSYSTEMTIME
LOCAL lRet AS LOGIC


   // ---------------


   nDays :=  nUnixDateTimestamp / 86400


   nSecondsRest1 :=   Mod ( nUnixDateTimestamp , 86400 )



    // -----------------------

   dWinDate :=  ConDate ( 1970 , 1 , 1 ) + nDays

    // --------------------

   nHoursTemp := nSecondsRest1 / 3600
   nSecondsRest2 := Mod ( nSecondsRest1 , 3600  )

    // -------------------

   nMinutesTemp := nSecondsRest2 / 60
   nSecondsRest3 := Mod ( nSecondsRest2 , 60  )

    // -------------------

   nSecondsTemp := nSecondsRest3




 IF lUTCGMT

  //  ref vars

      d := ConDate (  Year ( dWinDate )  , Month ( dWinDate )  , Day (
dWinDate ) )
    nHours := nHoursTemp
    nMinutes := nMinutesTemp
      nSeconds := nSecondsTemp

      lRet := TRUE


 ELSE

  s1 := MemAlloc ( _SIZEOF (  _WINSYSTEMTIME ) )
  s2 := MemAlloc ( _SIZEOF (  _WINSYSTEMTIME ) )


  s1.wYear := Year ( dWinDate )
    s1.wMonth := Month ( dWinDate )
    s1.wDay :=  Day (dWinDate )
     s1.wHour := nHoursTemp
    s1.wMinute := nMinutesTemp
    s1.wSecond := nSecondsTemp

    IF SystemTimeToTzSpecificLocalTime ( NULL , s1 , s2 )

       //  ref vars

      d := ConDate (  s2.wYear , s2.wMonth , s2.wDay )

   nHours := s2.wHour
   nMinutes := s2.wMinute
   nSeconds := s2.wSecond

       lRet := TRUE


    ENDIF

     MemFree ( s1 )
     MemFree ( s2 )

 ENDIF


 RETURN lRet


--- end -----


Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-12 18:39 -0400
  Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-13 13:49 +0200
    Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-13 12:34 -0400
      Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-14 09:57 +0200
      Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-15 18:27 +0200
        Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-15 21:31 -0400
          Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-16 14:45 +0200
            Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-16 18:49 +0300
              Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-17 08:49 +0200
        Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-16 17:26 +0200
          Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-16 14:08 -0400
            Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-17 09:30 +0200
              Re: GetTimeZoneDiff() documentation missing "Jamal" <someone@example.com> - 2014-06-17 10:37 -0400
                Re: GetTimeZoneDiff() documentation missing Camille Kater <katercam@pt.lu> - 2014-06-18 09:34 +0200
          Re: GetTimeZoneDiff() documentation missing "Karl-Heinz" <invalid@invalid.invalid> - 2014-06-17 08:47 +0200

csiph-web