1. GetTimeZoneInformation

Has anyone had any experience with the GetTimeZoneInformation Windows 
API?  I'm having some trouble understanding it's implementation and what 
the results should be.  I can get the bias information but am having 
trouble getting the standard name.  I also don't understand if the 
SYSTEMTIME structure is a returned value or if I have to pass a valid 
date/time?  HELP!!!!!

TIA...Jonas

Here's what I have so far:

include win32lib.ew

-- Time zone information structure
global constant TZ_INFO_Bias = allot(Long),
                TZ_INFO_StandardName = allot(Lpsz),
                TZ_INFO_StdDate_wYear = allot(Word),
                TZ_INFO_StdDate_wMonth = allot(Word),
                TZ_INFO_StdDate_wDayWk = allot(Word),
                TZ_INFO_StdDate_wDay = allot(Word),
                TZ_INFO_StdDate_wHour = allot(Word),
                TZ_INFO_StdDate_wMinute = allot(Word),
                TZ_INFO_StdDate_wSecond = allot(Word),
                TZ_INFO_StdDate_wMilliseconds = allot(Word),
                TZ_INFO_StandardBias = allot(Long),
                TZ_INFO_DaylightName = allot(Lpsz),
                TZ_INFO_DayDate_wYear = allot(Word),
                TZ_INFO_DayDate_wMonth = allot(Word),
                TZ_INFO_DayDate_wDayWk = allot(Word),
                TZ_INFO_DayDate_wDay = allot(Word),
                TZ_INFO_DayDate_wHour = allot(Word),
                TZ_INFO_DayDate_wMinute = allot(Word),
                TZ_INFO_DayDate_wSecond = allot(Word),
                TZ_INFO_DayDate_wMilliseconds = allot(Word),
                TZ_INFO_DaylightBias = allot(Long),
                SIZEOF_TZ_INFO = allotted_size()

global constant TIME_ZONE_ID_INVALID = #FFFFFFFF,
                TIME_ZONE_ID_UNKNOWN = 0,
                TIME_ZONE_ID_STANDARD = 1,
                TIME_ZONE_ID_DAYLIGHT = 2

constant xGetTimeZoneInformation = registerw32Function(kernel32, 
"GetTimeZoneInformation",
            {C_POINTER}, C_UINT)

global function GetTimeZoneInformation()

    atom rtn_code, xtime_zone, wrk_time, xstd_name, xday_name
    sequence rtn_time
    object wrk_obj

    rtn_time = {}

    xtime_zone = acquire_mem(0, SIZEOF_TZ_INFO)
    xstd_name = acquire_mem(0, 32)
    store(xtime_zone, TZ_INFO_StandardName, xstd_name)
    xday_name = acquire_mem(0, 32)
    store(xtime_zone, TZ_INFO_DaylightName, xday_name)
    store(xtime_zone, TZ_INFO_StdDate_wYear, 0)
    store(xtime_zone, TZ_INFO_StdDate_wMonth, 0)
    store(xtime_zone, TZ_INFO_StdDate_wDayWk, 0)
    store(xtime_zone, TZ_INFO_StdDate_wDay, 0)
    store(xtime_zone, TZ_INFO_StdDate_wHour, 0)
    store(xtime_zone, TZ_INFO_StdDate_wMinute, 0)
    store(xtime_zone, TZ_INFO_StdDate_wSecond, 0)
    store(xtime_zone, TZ_INFO_StdDate_wMilliseconds, 0)
    store(xtime_zone, TZ_INFO_DayDate_wYear, 0)
    store(xtime_zone, TZ_INFO_DayDate_wMonth, 0)
    store(xtime_zone, TZ_INFO_DayDate_wDayWk, 0)
    store(xtime_zone, TZ_INFO_DayDate_wDay, 0)
    store(xtime_zone, TZ_INFO_DayDate_wHour, 0)
    store(xtime_zone, TZ_INFO_DayDate_wMinute, 0)
    store(xtime_zone, TZ_INFO_DayDate_wSecond, 0)
    store(xtime_zone, TZ_INFO_DayDate_wMilliseconds, 0)


    rtn_code = w32Func(xGetTimeZoneInformation, {xtime_zone})

    -- Get the bias to UTC
    wrk_obj = fetch(xtime_zone, TZ_INFO_Bias)
    rtn_time = append(rtn_time, wrk_obj)
    -- Get standard time zone name
    wrk_obj = peek_string(xstd_name)
    rtn_time = append(rtn_time, wrk_obj)

    -- Get the standard date
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wYear)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wMonth)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wDayWk)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wDay)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wHour)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wMinute)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wSecond)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_StdDate_wMilliseconds)
    rtn_time = append(rtn_time, wrk_obj)

    -- Get the standard bias
    wrk_obj = fetch(xtime_zone, TZ_INFO_StandardBias)
    rtn_time = append(rtn_time, wrk_obj)
    -- Get the daylight name
    wrk_obj = peek_string(xday_name)
    rtn_time = append(rtn_time, wrk_obj)

    -- Get the daylight date
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wYear)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wMonth)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wDayWk)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wDay)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wHour)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wMinute)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wSecond)
    rtn_time = append(rtn_time, wrk_obj)
    wrk_obj = fetch(xtime_zone, TZ_INFO_DayDate_wMilliseconds)
    rtn_time = append(rtn_time, wrk_obj)

    -- Get the daylight bias
    wrk_obj = fetch(xtime_zone, TZ_INFO_DaylightBias)
    rtn_time = append(rtn_time, wrk_obj)

    release_mem(xtime_zone)

    return rtn_time

end function

new topic     » topic index » view message » categorize

2. Re: GetTimeZoneInformation

Hello Jonas!

Near as I can tell from the documentation (I don't use Windows anymore, s=
o I=20
can't test this), SYSTEMTIME is an element of the TIME_ZONE_INFORMATION=20
structure, whose pointer you are passing to GetTimeZoneInformation().  Th=
e=20
way it works is that you provide GetTimeZoneInformation() with the addres=
s to=20
a the TIME_ZONE_INFORMATION structure in which you want to receive the ti=
me=20
zone information.  The function then puts the information you need into t=
hat=20
structure.  So, basically, what you need to do is:

1.  allocate() your time zone info struct.
2.  Feed it to GetTimeZoneInformation().
3.  Go back to your time zone info struct (the one you allocated), and pe=
ek=20
the SYSTEMTIME structure within TIME_ZONE_INFORMATION.

This structure itself isn't the return value for GetTimeZoneInformation()=
, the=20
function merely fills in the structure ... as if you were to say, "There'=
s a=20
form on the desk.  Fill it out and leave it there."  The function fills o=
ut=20
the form (your structure) and leaves it there (where you allocated it), s=
o=20
you can go back and read it.  What GetTimeZoneInformation() returns is ju=
st=20
success/error information.

Hope this helps,

On Tuesday 28 January 2003 11:38 am, Jonas Temple wrote:
>=20
> Has anyone had any experience with the GetTimeZoneInformation Windows=20
> API?  I'm having some trouble understanding it's implementation and wha=
t=20
> the results should be.  I can get the bias information but am having=20
> trouble getting the standard name.  I also don't understand if the=20
> SYSTEMTIME structure is a returned value or if I have to pass a valid=20
> date/time?  HELP!!!!!

-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
Travis W. Beaty
Mason City, Iowa.
Linux User #302598
ICQ: 160291341
-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-

new topic     » goto parent     » topic index » view message » categorize

3. GetTimeZoneInformation

Hey everybody,

I figured out what I was doing wrong with GetTimeZoneInformation (WCHAR 
stands for WIDE character, who'da thunk?.  So you have to multiply the 
length by 2 to get the ACTUAL number of bytes).

I sent to Rob a zip file with my win32ext.ew, which is a trivial 
collection of Windows routines not found in win32lib.ew which contains 
the GetTimeZoneInformation routine.  Also included is a test program 
that outputs your time zone, local time and GMT time to a text file.

win32ext.ew also has routines to:

- Get the current user name
- Get the last error code and error text (you can call this, for 
example, when shellExecuteEx fails to display a message to the user)
- A wrapper for the SHFileOperation routine where you can move, copy, 
rename or delete files.

To run the timeztest.exw you'll need:
- win32lib (of course)
- win32ext
- version of misc.e that contains the pretty_print() routine
- datetime.e by Carl White (if you don't already have this one you 
should!  I don't think I have a program that DOESN'T use this include)

Have fun!

Jonas

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu