Question: how to convert a local Date & Time to UTC Date & Time 
Author Message
 Question: how to convert a local Date & Time to UTC Date & Time

Quote:

> I tried win32 APIs like SystemTimeToFileTime(...),
> LocalFileTimeToFileTime(...)
> and FileTimeToSystemTime(...) but it seems that I can't set and get the
> values for the

if its from a file you use localfiletimetofiletime, filetimetosystemtime
and then you can read the system time. I sounds like your prototype for
the system time structure may be off.  My code for disk time to:
SYSTIME     GROUP
wYear       ushort
wMonth      ushort
wDayOfWeek  ushort
wDay        ushort
wHour       ushort
wMinute     ushort
wSecond     ushort
wMilliseconds    ushort
            END
MyFileTime  group
lowtime     ulong
hitime      ulong
        end

    if FileTimeToLocalFileTime(AddrDosDate,Address(MyFileTime)) then
      !Convert to system time
      if FileTimeToSystemTime(Address(MyFileTime),address(SysTime)) then
        !Put in clarion format
        ClarionDate = DATE(SysTime.wmonth,SysTime.wDay,SysTime.wYear)
        ClarionTime = (SysTime.wHour * 360000) + (SysTime.wMinute *6000)
+ |
                       (SysTime.wSecond * 100) + (SysTime.wMilliSeconds /
10) + 1
      else
        res=1
      end
    else
      res=1
    end
    return(res)

---
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com



Sun, 30 Sep 2001 03:00:00 GMT  
 Question: how to convert a local Date & Time to UTC Date & Time
Robert,

Here is a bit of code that I extracted from a procedure that does just that.
INI:ZuluToLocalOffset is a byte that contains the number of hours from local
standard to UTC time, and INI:DaylightSavingsUsed is a flag that is set if
DST is used in your part of the world.

Cheers!

Rob

!Convert Local Time and Date to UTC Time and Date
  UTCOffset=INI:ZuluToLocalOffset*360000  ! # hours offset from Zulu to
Local
!  MESSAGE(INI:DaylightSavingsUsed)
  IF INI:DaylightSavingsUsed THEN
    Dst#=FALSE
    FirstSunday#=DATE(4,7,YEAR(LclDate))
    FirstSunday#=FirstSunday#-(FirstSunday# % 7)
    LastSunday#=DATE(10,31,YEAR(LclDate))
    LastSunday#=LastSunday#-(LastSunday# % 7)
    IF LclDate>FirstSunday# AND LclDate<LastSunday# THEN Dst#=TRUE .
    IF LclDate=FirstSunday# AND LclTime>=720000 THEN DST#=TRUE .
    IF LclDate=LastSunday# AND LclTime<720000 THEN DST#=TRUE .
    IF Dst# THEN
      UtcOffset-=360000            !Add DST offset to time field
    .
  .
  LclTime=LclTime+UTCOffset
  IF LclTime> 8640000 THEN
    LclTime=LclTime-8640000
    LclDate=LclDate+1
  .
  IF LclTime<=0 THEN
    LclTime=LclTime+8640000
    LclDate=LclDate-1
  .
  RETURN

Quote:

>Hi all,

>Does anyone know how to convert a local Date & Time to UTC Date & Time ?

>I tried win32 APIs like SystemTimeToFileTime(...),
>LocalFileTimeToFileTime(...)
>and FileTimeToSystemTime(...) but it seems that I can't set and get the
>values for the
>data structure SYSTEMTIME like
>systemtime1.wDay = 2
>Furthermore, if I use the API call GetSystemTime(systemtime1) ,
>I get a big number when MESSAGE(Systemtime1.wDay)
>The definition for the APIs is generated by the Clarion's WinAPI tool
>and systemtime1 is GROUP(SYSTEMTIME).

>Can anyone tell me what's wrong here ?
>Or any better way to do the conversion?

>Thanks very much in advance.

>Regards
>Robert



Sun, 30 Sep 2001 03:00:00 GMT  
 Question: how to convert a local Date & Time to UTC Date & Time
Hi all,

Does anyone know how to convert a local Date & Time to UTC Date & Time ?

I tried win32 APIs like SystemTimeToFileTime(...),
LocalFileTimeToFileTime(...)
and FileTimeToSystemTime(...) but it seems that I can't set and get the
values for the
data structure SYSTEMTIME like
systemtime1.wDay = 2
Furthermore, if I use the API call GetSystemTime(systemtime1) ,
I get a big number when MESSAGE(Systemtime1.wDay)
The definition for the APIs is generated by the Clarion's WinAPI tool
and systemtime1 is GROUP(SYSTEMTIME).

Can anyone tell me what's wrong here ?
Or any better way to do the conversion?

Thanks very much in advance.

Regards
Robert



Mon, 01 Oct 2001 03:00:00 GMT  
 Question: how to convert a local Date & Time to UTC Date & Time
Hi Jim,

Quote:


> > I tried win32 APIs like SystemTimeToFileTime(...),
> > LocalFileTimeToFileTime(...)
> > and FileTimeToSystemTime(...) but it seems that I can't set and get the
> > values for the

> if its from a file you use localfiletimetofiletime, filetimetosystemtime
> and then you can read the system time. I sounds like your prototype for
> the system time structure may be off.  My code for disk time to:
> SYSTIME     GROUP
> wYear       ushort
> wMonth      ushort
> wDayOfWeek  ushort
> wDay        ushort
> wHour       ushort
> wMinute     ushort
> wSecond     ushort
> wMilliseconds    ushort
>             END
> MyFileTime  group
> lowtime     ulong
> hitime      ulong
>         end

You are right. It works fine now .
It seems  that the Winapi sample application generated wrong structure for
SYSTEMTIME and FILETIME.
Thanks very much for you help

Regards
Robert



Fri, 05 Oct 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. convert labview date/time to excel date/time

2. TIME&DATE in HTML shows TIME

3. Create Time / date or Modified Time / date of a txt file

4. DOS compressed date/time into real date/time

5. Time & Date question

6. Dos Date & time to clarion date & time

7. Reasonably portable date & time formatter

8. Time & date fns for APL*PLUS SE

9. File date & time

10. Date & Time

11. File Date & Time

12. Record Change Time & Date Embed

 

 
Powered by phpBB® Forum Software