<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="1001340">
  <date_last_updated>2012-06-14 11:51:24.902126+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/1001340</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~mail-jfalch</bug_owner_link>
    <milestone_link>https://api.launchpad.net/1.0/maria/+milestone/5.5</milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/1001340/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/1001340/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/1001340</bug_web_link>
  <owner>Jürgen Falch</owner>
  <assignee>Vladislav Vaintroub</assignee>
  <milestone_title>Maria 5.5</milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>system_time_zone is set wrong</title>
  <status>New</status>
  <importance>Medium</importance>
  <created>2012-05-18 16:43:08.479197+00:00</created>
  <description>
<![CDATA[In v5.5.23 on XP SP3, the server variable system_time _zone is set to a wrong value on server startup. Its value is "ope" (without the quotes), not a valid time zone designation. 
IMHO, this is possibly derived form the string "Westeuropäische Sommerzeit" which is returned by the GetTimeZoneInformation() windows API call on my machine (meaning CEST, +02:00).

Note: I have an environment variable called TZ, whose current value is "CET" (without the quotes). 
If I unset this variable inside a cmd.exe window, and then start mysqld.exe --console from same window, system_time _zone will be different, namely "Westeuropische Sommerzeit" (without the quotes) - note the missing "ä". 
Again, this appears not to be a valid timezone name according to the mysql.time_zone_name table.

The correct value would probably be CET or Europe/Berlin.]]>  </description>
  <activities>
    <activity datechanged="2012-05-18T16:43:08.479197+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Jürgen Falch</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2012-05-18T16:55:17.508098+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Vladislav Vaintroub (wlad-montyprogram)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Elena Stepanova</person>
      <message></message>
    </activity>
    <activity datechanged="2012-06-14T11:40:37.002019+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[5.5]]>      </newvalue>
      <whatchanged>maria: milestone</whatchanged>
      <person>Vladislav Vaintroub</person>
      <message></message>
    </activity>
    <activity datechanged="2012-06-14T11:51:23.744134+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[Medium]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Vladislav Vaintroub</person>
      <message></message>
    </activity>
  </activities>
  <comments>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/1001340/comments/1" datecreated="2012-05-18T17:53:35.561013+00:00">
      <person>Jürgen Falch</person>
      <subject>
<![CDATA[Re: system_time_zone is set wrong]]>      </subject>
      <content>
<![CDATA[After some searching, the problem is most probably that the time zone name returned from the windows registry.by GetTimeZoneInformation() is a) non-standard and b) localized.  You could probably scan the subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones until you find one whose Std or Dlt value is equal to the GetTimeZoneInformation() result (not necessarily identical to the subkey name!). Then parse the TZI value of the same entry for the appropriate bias'es (cf http://www.pcmag.com/article2/0,1895,1166624,00.asp for format info), and use the computed bias as +|-nn:nn.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/1001340/comments/2" datecreated="2012-05-18T19:00:44.591774+00:00">
      <person>Jürgen Falch</person>
      <subject>
<![CDATA[Re: system_time_zone is set wrong]]>      </subject>
      <content>
<![CDATA[...or you could just use the appropriate bias'es from the TIME_ZONE_INFORMATION result structure returned by GetTimeZoneInformation() ... d'oh.]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/1001340/comments/3" datecreated="2012-05-18T20:48:57.877274+00:00">
      <person>Vladislav Vaintroub</person>
      <subject>
<![CDATA[Re: system_time_zone is set wrong]]>      </subject>
      <content>
<![CDATA[Jürgen,
 I do not have localized Windows atm. Would it be possible for you to compile and run this program and paste the results?

#include <stdio.h>
#include <windows.h>

int main()
{
  TIME_ZONE_INFORMATION tzi;
  GetTimeZoneInformation(&tzi);
  wprintf(L"%s\n", tzi.StandardName);
  wprintf(L"%s\n", tzi.DaylightName);
  return 0;
}

It does not return 3 letter abbreviation for me,  but instead

W. Europe Standard Time
W. Europe Daylight Time

I consider this ok, since the doc explicitely states that the result can be OS-dependent. However I'd rather avoid non-ASCIIs and stay English . So, I'm basically wondering if localized Windows would return localized results.
]]>      </content>
    </comment>
    <comment commentlink="https://api.launchpad.net/1.0/maria/+bug/1001340/comments/4" datecreated="2012-05-18T23:39:49+00:00">
      <person>Jürgen Falch</person>
      <subject>
<![CDATA[Re: [Bug 1001340] Re: system_time_zone is set wrong]]>      </subject>
      <content>
<![CDATA[Hi,

> It does not return 3 letter abbreviation for me,  but instead
> W. Europe Standard Time
> W. Europe Daylight Time
the test program returns:
Westeuropäische Normalzeit
Westeuropäische Sommerzeit

> So, I'm basically wondering if localized Windows would return localized> results.
I have googled quite a lot on this, and experimented some. The result appears to be that on a localized windows, the time zone 
names returned by GetTimeZoneInformation() are always a) localized, b) "long" names and c) invented by someone at Microsoft, 
ie not textually equal to standard Unix/etc timezone names (as found in mysql.time_zone_names).

If such localized Microsoft-specific timezone names are understood inside mysqld, (ie when setting system_time_zone), there is 
no bug/problem.

If not, please be so kind as to read my comments to the bug report, especially the second one.
IMHO, a simple way to obtain a valid value for system_time_zone on windows, localized or not, would be:
call GetTimeZoneInformation(&tzi) where tzi is a variable of type TIME_ZONE_INFORMATION:
if the resulting value is 1 (TIME_ZONE_ID_STANDARD), bias= tzi.Bias + tzi.StandardBias;
if the resulting value is 2 (TIME_ZONE_ID_DAYLIGHT), bias= tzi.Bias + tzi.DaylightBias;
(if the resulting value should be other (0), the timezone can not be determined - should not happen.)
Convert the resulting bias (unit: minutes, signed) to +|-hh:mm format, and you should be done.

Best regards,

-- 
Jürgen Falch
PGP: D4D92BB3

]]>      </content>
    </comment>
  </comments>
</launchpad-bug>
