Is Npgsql.EnableLegacyTimestampBehavior going to be removed in a next version?
See original GitHub issueThe new behavior, frankly, makes no sense to me. We already use UTC everywhere for System.DateTime, and each date is always passed around as UTC, without any time zone modifications, until it’s necessary for a particular user in a particular time zone. The old Npgsql version also just took the date and sent it to the database as is. The new version does some weird arithmetics with the local time zone of the machine where the code’s running (UTC everywhere is used specifically not to think about this local time zone, which is irrelevant for web apps and such!) instead of just sending the date as is. And if the column still has timestamp without time zone type, the value sent by Npgsql, like 2021-12-28 10:00:00+10, gets truncated to just 2021-12-28 10:00:00, the value that appears nowhere in the .NET code that generated and processed the value 2021-12-28 00:00:00 UTC.
The only good part of the new behavior is probably exceptions thrown when Npgsql gets unexpected non-UTC dates, but in the context even that is bad, since it prevents using the new Npgsql so that dates are treated as UTC and they’re not modified when being written.
Is the old behavior going to be supported going forward, or the new behavior will be forced on us?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top Related StackOverflow Question
Yes, there are many real-world situations; I prefer that UPS tells me by mail in my clock time when a package from Greece will arrive 😉
When tables are created using our engine, it is timestamp without timezone. For the rest we will probably make it work again and forward the real business decisions to end users.
To me that really sounds like you’d want to set TimeZone to GMT. In effect this even removes the difference between
timestamp without time zoneandtimestamp with time zoneand renders your database to being just a dumb storage that just stores the data as they are passed without doing any implicit conversions.