Bug #76266 Erroneous UTC timezone reporting

Submitted: 11 Mar 2015 19:45 Modified: 12 Mar 2015 7:30
Reporter: Kevin Cuzner Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.9.5 OS:Windows
Assigned to: CPU Architecture:Any

[11 Mar 2015 19:45] Kevin Cuzner
Description:
According to the changelog of Connector/NET 6.6.4 (http://dev.mysql.com/doc/relnotes/connector-net/en/connector-net-news-6-6-4.html), Connector/NET will create DateTime objects as Kind=UTC if the reported timezone offset is +0:00 (time_zone property is utc). Otherwise, it reports Kind=Local.

Using EntityFramework 6.x with Connector/NET 6.8.3 or 6.9.5 (haven't tested this with any versions in between) appears to erroneously report timestamps as Kind=UTC when the timezone offset is not UTC (-6:00 in my case).

The MySQL server version is 5.6.12, tables are InnoDB, and the server OS is OSX 10.6. The Connector/NET is being used on a Windows 8 machine in a .NET 4.5 project (MVC5+WebAPI2). It was installed in the project via NuGet.

How to repeat:
Let "var context" be an Entity Framework 6.x context.

Let there be a table with the following definition called 'records'. It is represented on the Entity Framework 6.x context as "DbSet<record> records".

+-----------+-------------+------+-----+-------------------+----------------+
| Field     | Type        | Null | Key | Default           | Extra          |
+-----------+-------------+------+-----+-------------------+----------------+
| id        | int(11)     | NO   | PRI | NULL              | auto_increment |
| timestamp | varchar(20) | YES  |     | CURRENT_TIMESTAMP |                |
+-----------+-------------+------+-----+-------------------+----------------+

Let the server timezone be listed as America/Denver and the separate web server also have that same timezone. Assume the clocks are in sync.

Execute the following to establish that the offset is not +0:00:

var tz = context.Database.SqlQuery<string>("SELECT TIMEDIFF( CURTIME(), UTC_TIME() )").FirstOrDefault();

tz will contain "-06:00:00".

Assume the time is 13:00:00 MDT(-6:00). Execute the following:

var r = new record() { };
context.records.Add(r);
context.SaveChanges(); //r.timestamp now contains {3/11/2015 1:00:00 PM}, Kind=UTC

At this point, "r.timestamp" is wrong. Since it contains 1PM with Kind=UTC, it will be serialized to "2015-03-11T13:00:00Z" per ISO 8601. When this is parsed by something such as momentjs, it will be parsed as if it were 1PM GMT and converted into the "local" time, resulting in a time of "2015/03/11 07:00:00" for -6:00.

This same behavior would also be seen if we executed the following:

var rec = context.records.FirstOrDefault();

"rec.timestamp" will contain a DateTime with the Date and Time properties set to the local (-6:00 converted) time, but the Kind=UTC.
[12 Mar 2015 7:30] Chiranjeevi Battula
Hello Kevin Cuzner,

Thank you for the bug report.
Similar UTC timezone issue has been reported(Bug #74905) in the past and issue was fixed in 6.9.6 version. Please try MySQL Connector/Net 6.9.6 and let us know if you are still having the issue.
http://dev.mysql.com/doc/relnotes/connector-net/en/connector-net-news-6-9-6.html

Thanks,
Chiranjeevi.
[12 Mar 2015 7:30] Chiranjeevi Battula
time difference screenshot

Attachment: 76266.PNG (image/png, text), 7.50 KiB.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.