question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Read DateTimeOffset with the PostgreSQL TIMEZONE

See original GitHub issue

When reading a NodaTime ZonedDateTime from a PostgreSQL timestamp with time zone, we look at the PostgreSQL connection’s Timezone parameter and return a ZonedDateTime in that timezone - this mimics the general PostgreSQL behavior when not using Npgsql.

We did not implement this for non-NodaTime DateTimeOffset, because PostgreSQL timezones are in IANA format, but .NET did not support those up to now - but that’s been done: https://github.com/dotnet/runtime/pull/49412. This means we can now start returning DateTimeOffset in the appropriate timezone, instead of in ~UTC~ the machine’s configured timezone.

On the downside, this would be a breaking change; even more tricky, the IANA support is only going to be available in .NET 6.0, so this would possibly mean a behavioral change depending on which .NET is being used (or we throw NotSupported or something. We can discuss.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
vonzshikcommented, Mar 13, 2021

I’m adding this to the backlog for now, let’s think about it for 7.0 (at the very least, by that time we will have multiple TFMs supporting this API, so it should be less risky).

1reaction
vonzshikcommented, Mar 12, 2021

Dropping the support for the DateTimeOffset for .NET versions below 6.0 is a pretty huge breaking change IMO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date and Time Handling
EnableLegacyTimestampBehavior is enabled), reading a timestamp with time zone as a DateTimeOffset returns a local offset based on the timezone of the server ......
Read more >
How to store DateTimeOffset in PostreSQL
I am using the Timestamp With Time Zone type in postgreSQL for the CameraDate field. I can't figure out how to get this...
Read more >
Documentation: 15: 8.5. Date/Time Types
PostgreSQL assumes your local time zone for any type containing only date or time. All timezone-aware dates and times are stored internally in...
Read more >
PostgreSQL Timestamps and Timezones: What You Need ...
When a timestamptz value is set, the system computes the local time in UTC to which this corresponds and records this, using the...
Read more >
DateTimeOffset using PostgreSQL and timestamptz column ...
I have a column in my table that is of data type 'timestamp with time zone' and I'm trying to map that to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found