GetDateTimeOffset exception around DST change
Posted: Tue 07 May 2013 23:36
In our Postgres db we have a field defined as:
samples_timestamp timestamp with time zone NOT NULL
Our code reads records from one db and writes a copy of it to another db. These databases can be in different time zones, so we use the PgSqlDataReader and GetDateTimeOffset to ensure we can correctly assign the time offset when we build the SQL insert statement. This works correctly except when the timestamp is within a few hours of the Daylight Saving Time (DST) change. Then the call to GetDateTimeOffset throws an exception. We are in Pacific time so the pre-DST offset is -08.
Example timestamp: "2013-03-09 19:50:00.02-08"
Here is the exception:
The UTC Offset of the local dateTime parameter does not match the offset argument. Parameter name: offset
at System.DateTimeOffset..ctor(DateTime dateTime, TimeSpan offset)
at Devart.Data.PostgreSql.j.ba(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.PostgreSql.PgSqlDataReader.GetDateTimeOffset(Int32 i)
Please advise if there is a workaround and if this will be fixed. We are using version 6.2.122 and I have also tried using 6.6.226 and it also fails. Our db is Postgres 9.1.9.
samples_timestamp timestamp with time zone NOT NULL
Our code reads records from one db and writes a copy of it to another db. These databases can be in different time zones, so we use the PgSqlDataReader and GetDateTimeOffset to ensure we can correctly assign the time offset when we build the SQL insert statement. This works correctly except when the timestamp is within a few hours of the Daylight Saving Time (DST) change. Then the call to GetDateTimeOffset throws an exception. We are in Pacific time so the pre-DST offset is -08.
Example timestamp: "2013-03-09 19:50:00.02-08"
Here is the exception:
The UTC Offset of the local dateTime parameter does not match the offset argument. Parameter name: offset
at System.DateTimeOffset..ctor(DateTime dateTime, TimeSpan offset)
at Devart.Data.PostgreSql.j.ba(Byte[] A_0, Int32 A_1, Int32 A_2)
at Devart.Data.PostgreSql.PgSqlDataReader.GetDateTimeOffset(Int32 i)
Please advise if there is a workaround and if this will be fixed. We are using version 6.2.122 and I have also tried using 6.6.226 and it also fails. Our db is Postgres 9.1.9.