The issue
Reading "timestamp with tz" from database into a DateTimeOffset causes dates to be converted into a local date time. I'm wondering if it would be possible to add configuration to allow keeping DateTimeOffset in UTC.
Specifically in in TimeStampTzHandler.cs:
DateTimeOffset INpgsqlSimpleTypeHandler<DateTimeOffset>.Read(NpgsqlReadBuffer buf, int len, FieldDescription? fieldDescription)
{
// TODO: Convert directly to DateTime without passing through NpgsqlTimeStamp?
var ts = ReadTimeStamp(buf, len, fieldDescription);
if (ts.IsFinite)
return ts.ToDateTime().ToLocalTime();
allowing someway to configure whether the ToLocalTime() is called there or not. This has impact when serializing the DateTimeOffset since when calling ToLocalTime() will cause the offset to be added to the ISO8601 string which I'm trying to avoid in this case.
Further technical details
Npgsql version: 4.1.3.1
PostgreSQL version: 9.6
Operating system: OSX Catalina
Other details about my project setup: .NET Core 3.1
The issue
Reading "timestamp with tz" from database into a DateTimeOffset causes dates to be converted into a local date time. I'm wondering if it would be possible to add configuration to allow keeping DateTimeOffset in UTC.
Specifically in in TimeStampTzHandler.cs:
allowing someway to configure whether the
ToLocalTime()is called there or not. This has impact when serializing the DateTimeOffset since when callingToLocalTime()will cause the offset to be added to the ISO8601 string which I'm trying to avoid in this case.Further technical details
Npgsql version: 4.1.3.1
PostgreSQL version: 9.6
Operating system: OSX Catalina
Other details about my project setup: .NET Core 3.1