Daylight savings bug
Posted: Tue 06 Oct 2015 00:52
Hi,
We are experiencing a bug in the dotConnect provider for Postgresql (7.3.X , though I have tested a trial of latest as well).
Example scenario:
1. Set host to Australian Eastern Standard Time.
2. Insert a record on the day daylight savings had switched on, which here this year was Sunday Oct 4.
i.e. cmd.CommandText = "INSERT INTO \"MyTable\" (\"MyDate\") VALUES ('2015-10-04 08:24:15+11')";
(daylight savings here is +11, while standard time is +10).
3. Retrieve the date from the db.... i.e. something like
using (var cmd = new PgSqlCommand())
{
cmd.Connection = _pgConn;
cmd.CommandText = "SELECT \"MyDate\" FROM \"MyTable\"";
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
dateReturned = reader.GetDateTime(0);
}
}
}
Assert.That(dateReturned, Is.EqualTo(DateTime.Parse("2015-10-04 08:24:15+11")));
//Fails! Expected: 2015-10-04 08:24:15.000 But was: 2015-10-04 07:24:15.000
It has treated the date like it was before DST when moving it back to local.
I have a nunit test reproducing the issue if you need. This is impacting a production system for us. The same test works fine in npgsql.
The problem only occurs on the date daylight savings was switched on or off, only when the timezone of the machine is set locally (I've only tested AEST, but suspect it is general issue), and not for the full day (I think when the date in UTC falls onto the same date here, the problem stops).
We are experiencing a bug in the dotConnect provider for Postgresql (7.3.X , though I have tested a trial of latest as well).
Example scenario:
1. Set host to Australian Eastern Standard Time.
2. Insert a record on the day daylight savings had switched on, which here this year was Sunday Oct 4.
i.e. cmd.CommandText = "INSERT INTO \"MyTable\" (\"MyDate\") VALUES ('2015-10-04 08:24:15+11')";
(daylight savings here is +11, while standard time is +10).
3. Retrieve the date from the db.... i.e. something like
using (var cmd = new PgSqlCommand())
{
cmd.Connection = _pgConn;
cmd.CommandText = "SELECT \"MyDate\" FROM \"MyTable\"";
using (var reader = cmd.ExecuteReader())
{
while (reader.Read())
{
dateReturned = reader.GetDateTime(0);
}
}
}
Assert.That(dateReturned, Is.EqualTo(DateTime.Parse("2015-10-04 08:24:15+11")));
//Fails! Expected: 2015-10-04 08:24:15.000 But was: 2015-10-04 07:24:15.000
It has treated the date like it was before DST when moving it back to local.
I have a nunit test reproducing the issue if you need. This is impacting a production system for us. The same test works fine in npgsql.
The problem only occurs on the date daylight savings was switched on or off, only when the timezone of the machine is set locally (I've only tested AEST, but suspect it is general issue), and not for the full day (I think when the date in UTC falls onto the same date here, the problem stops).