-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
No ZonedDateTimeType #1
Comments
Hi @mnavarrocarter, thank you for your support! Indeed, the lack of Some arguments:
If anything, we could provide support for databases that do support an explicit timezone (Postgres, AFAICS?), but I'm not sure if providing broken support for other databases such as MySQL is a good idea. What database do you use? Do you have better ideas? |
Hi @BenMorel, your comments launched me into research and I think I discovered a flaw in the way I'm doing things. I'm using PostgreSQL. Along with Oracle they are the only two vendors that support storing dates with timezone information. But they do not store that information using a timezone name (i.e. Europe/London) but rather the the timezone offset. This may cause tricky issues with DST situations. I'm storing them like that, and I should fix that immediately, since I need the timezone name and not the offset. Now, with that in mind, I have some thoughts on your arguments.
I think this makes sense in my head, but I'm very opened to discussion on potential issues of this approach or corrections of my understanding. I'm by no means an expert, but I have some experience maintaining a multi-tenant booking application for a US client. We display dates in the client timezone (that we obtain from configuration). Everything in UTC is a rule that has worked great for us. No confusions, since UTC is sort of an absolute representation. Thanks so much Ben for taking the time to reply. I know you maintain a lot of packages and that must be very busy. I just want to add on a personal note that I've followed your work from a couple of years now and I admire you for it. Your packages are of a tremendous quality. Hope we can meet in person at a conference one day! |
Hi Matias, I really have a problem with In the current state of things, and unless we're storing the If we want to support
It really makes me happy to know that my packages are useful to people, so thanks a lot for your kind words; it'd be a pleasure to meet in person! |
Hi Ben I think the
|
Hi, first of all thanks a lot for sponsoring me, it means a lot to me! 🎉 I played a bit with PostgreSQL's CREATE TABLE x (
ts TIMESTAMP WITH TIME ZONE
);
INSERT INTO x VALUES('2021-04-28 23:13:00+00');
INSERT INTO x VALUES('2021-04-28 23:13:00+02');
SELECT * FROM x;
Did I miss something? |
You are most welcome! Oh, I'll check with my Pg setup and get back to you. |
I'm evaluating to switch to the |
I think I might shed some light here. It is my understanding that when any piece of software represents time, it does so by using the unix time since the epoch, so an The Instant (seconds since the epoch) is the absolute time. Timezone information is just a presentation concern. For instance, changing the timezone of a I hope that helped. :) |
That's clear. In MySQL, a value stored in a
Regarding this, I don't understand why an |
@BenMorel probably. To quote the docs:
you can Hopefully this demonstrates it: CREATE TABLE x (
ts TIMESTAMP WITHOUT TIME ZONE,
tstz TIMESTAMP WITH TIME ZONE
);
SET timezone = 'Europe/London';
INSERT INTO x (ts, tstz)
VALUES('2021-04-28 23:13:00-04','2021-04-28 23:13:00-04');
INSERT 0 1
TABLE x;
ts | tstz
---------------------+------------------------
2021-04-28 23:13:00 | 2021-04-29 04:13:00+01
(1 row)
SET timezone = 'America/New_York';
TABLE x;
ts | tstz
---------------------+------------------------
2021-04-28 23:13:00 | 2021-04-28 23:13:00-04
(1 row)
SET timezone = 'America/Los_Angeles';
TABLE x;
ts | tstz
---------------------+------------------------
2021-04-28 23:13:00 | 2021-04-28 20:13:00-07
(1 row) Since postgres stores the value in UTC (and not the original offset) it's impossible to guarantee that inserting a if this is acceptable then you could implement |
Hey @BenMorel thank you for this package. I always use this library for my entities, and I always made the types myself. I'm going to switch to this one, so thank you a lot for making it available.
I just have one question. Why not a
ZonedDateTimeType
? I understand this could be due to some databases not supporting timezones in their datetime types, but we could always convert it to utc prior to storage, right?Please correct me if I'm wrong.
The text was updated successfully, but these errors were encountered: