Bug #74134 GetTimeZoneOffset doesn't work
Submitted: 29 Sep 2014 12:31 Modified: 20 Feb 2015 6:18
Reporter: Maxim Ter Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.4 OS:Any
Assigned to: Roberto Ezequiel Garcia Ballesteros CPU Architecture:Any
Tags: connector, TimeZoneOffset

[29 Sep 2014 12:31] Maxim Ter
Description:
While calling GetTimeZoneOffset method in Driver.cs, the string s = cmd.ExecuteScalar() as string; is null.

As a result, TimeZone offest is not calculated correctly later in GetDateTime method of datareader.cs since driver.timeZoneOffset is always = 0.

How to repeat:
Try to install MySQL server on a timezone different than UTC and see whether you get in driver.timeZoneOffset correct value.

Suggested fix:
Instead of 
string s = cmd.ExecuteScalar() as string;
we did 
object timeDiff = cmd.ExecuteScalar();
string s = timeDiff == null ? null : timeDiff.ToString();

and it fixes the issue.
[17 Nov 2014 19:33] Nicholas Schell
I would like to confirm this issue.
The object returned by "cmd.ExecuteScalar()" is actually a TimeSpan. I am guessing this is from the timediff sql function used. So clearly it will never cast as a String. Until this is fixed it means ALL DateTimes are set as UTC Kind, which is obviously a huge issue the further away you are from UTC. This was changed sometime in the 6.9.x branch I believe because it was not in 6.8.3.
[20 Feb 2015 6:18] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Net 6.9.6 release, and here's the changelog entry:

With the "Driver.GetTimeZoneOffset" method, the TimeZone offset was not
calculated correctly, and instead it was always set to 0. In other words,
this caused the time zone to always be set to UTC.

Thank you for the bug report.