-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider changing from ZonedDateTime to OffsetDateTime in date2 plugin #248
Comments
@madkinder slick-pg supports them both. You can check it. ;-) But because of #220, the time zone info may be lost. |
Well, the base case of using Given the column definition "targeting_period" TSTZRANGE NOT NULL and column mapping definition def targetingPeriod = column[Option[Range[OffsetDateTime]]]("targeting_period", O.Default(None)) I get the following error
It does work when I change As for the the original question. Even though slick-pg supports both |
Hi @madkinder, slick-pg's date2 addon supports both ZonedDateTime and OffsetDateTime, but not in range support.
|
Hi guys ! Would be cool to update the docs with the compatibility of |
@callicles yes, it's welcome! |
Apparently if you want to keep the offset, you should add a distinct value in seconds, and then map the offset from there https://stackoverflow.com/questions/54189839/how-to-store-offsetdatetime-to-postgresql-timestamp-with-time-zone-column |
To my mind it would be more appropriate to use
OffsetDateTime
instead ofZonedDateTime
to representtimestamptz
.Here's an excerpt from ZonedDateTime javadoc:
The notable thing here is "and a time-zone" part.
Here's an excerpt from Postgres manual 8.5.3. Time Zones:
As you can see, there's a discrepancy between
ZonedDateTime
andtimestamptz
handling of the time zone. The class does store the time zone (e.g. Australia/Sydney) while the column does not and relies on the database configuration option.So if you have an instance of
ZonedDateTime
, store it in the database, then fetch it back you are not guaranteed to get the same time zone as the original class instance.On the other hand even if you use
OffsetDateTime
you are not guaranteed to get the same time offset (e.g. +03:00) back either. But anyways it is a bit better, because either way or another you get back the very same time instant that you stored if you useOffsetDateTime
which might not be the case withZonedDateTime
.The text was updated successfully, but these errors were encountered: