This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

automatic TZ env-variable in localtime "problem" with W2000-german

I have the following problem, or misunderstandig(!) of TZ variable in

Problem (and my current solution)

When I do not set TZ to a valid value, all times will be showed as GMT (or
UTC) time.
The automatic generated TZ variable in will generate a name
from GetTimeZoneInformation.

When I test this algorithm in a program, the name will be invalid (longer
than 3 characters).

At the moment I have problems to rebuild the cygwin1.dll (make will make a
lot of things but I do find a simple make cygwin1.dll...)

Is it a good, bad, very bad idea to test the length of the name against 3 to
generate a TZ variable compatible with tzparse? (not tested, because I was not able to build cygwin1.dll)

	    for (src = tz.StandardName; *src; src++)
	      if (is_upper(*src)) *dst++ = *src;

	    /* not 3 characters for timezone _tzname[0] ? 
               happens for example in Win2000/NT german version
               a) tz.StandardName is a WideChar String
               b) is very long "Westeropaische Normalzeit"
               generate a TZ variable relative to GMT-x
               (if strlen of _tzname is not equal 3 , tzparse will 
                not accept the TZ variable!)
               mkt */
            if (strlen(cp) != 3)            /* mkt */
            {                               /* mkt */
               strcpy(cp, "GMT");           /* mkt */
               dst = cp + 3;                /* mkt */
            }                               /* mkt */

(...) same for the daylight saving time with DST.

When I call this function as a separate routine win32_tzset (roughly written
in win32_tzset.c for my VC program and Cygwin-GNU ports) the TZ variable
will be understood and the correct times will be chown.

pdksh port with a call to win32_tzset to set TZ automatically from Windows
Control Panel:
pdksh $ echo $TZ
pdksh $ date
Mon Feb 11 17:35:54  2002
(yes this the current time)

bash-2.05a$ date
Mon Feb 11 16:36:25  2002
(no, this the UTC time)

 <<win32_tzset.c>>  <<>> 

Attachment: win32_tzset.c
Description: Binary data

Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]