As described in the referenced issue, the way tiberius converts between DateTime<FixedOffset> and DateTimeOffset is incorrect.
Currently, tiberius uses the DateTime<FixedOffset>'s local datetime + offset to create the DateTimeOffset.
This means that what is stored in the database will be a local datetime and its offset.
"The data is stored in the database and processed, compared, sorted, and indexed in the server as in UTC. The time zone offset will be preserved in the database for retrieval."
the value should be stored in the database as a UTC datetime + offset.
The consequence of tiberius's current behavior is that retrieving DateTimeOffset values, that have been inserted by tiberius, using any other methods or languages will yield the wrong value.
Likewise, using tiberius to retrieve values that have been inserted by other methods or languages will also yield the wrong value.
Changes
Changes the conversion between DateTime<FixedOffset> and DateTimeOffset to use UTC + offset instead of local + offset.
Adds a test that demonstrates the problem, which fails without these changes.
Rebased version of https://github.com/prisma/tiberius/pull/261
Problem
As described in the referenced issue, the way tiberius converts between
DateTime<FixedOffset>
andDateTimeOffset
is incorrect. Currently, tiberius uses theDateTime<FixedOffset>
's local datetime + offset to create theDateTimeOffset
. This means that what is stored in the database will be a local datetime and its offset.However, as described in the docs:
"The data is stored in the database and processed, compared, sorted, and indexed in the server as in UTC. The time zone offset will be preserved in the database for retrieval."
the value should be stored in the database as a UTC datetime + offset.
The consequence of tiberius's current behavior is that retrieving
DateTimeOffset
values, that have been inserted by tiberius, using any other methods or languages will yield the wrong value. Likewise, using tiberius to retrieve values that have been inserted by other methods or languages will also yield the wrong value.Changes
DateTime<FixedOffset>
andDateTimeOffset
to use UTC + offset instead of local + offset.Closes https://github.com/prisma/tiberius/issues/260