-
Notifications
You must be signed in to change notification settings - Fork 21
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
Converting non-UTC timezones to UTC during cast #29
Comments
If you use Postgres you can use the Calecto.DateTime type. Also see this article http://www.creativedeletion.com/2015/03/19/persisting_future_datetimes.html If you know the time zone you can do that. If you don't you can use What the Calecto.DateTime type does is save both the time zone identifier (e.g. America/New_York) and the local "wall time". In this case the wall time would be the time it is specific time zone. If you don't use postgres you could also manually handle saving both the time zone identifier and the wall time in two separate fields. |
Hi!
I think it would be ideal to have the possibility to define types for specific time zones. That time would be persisted as UTC to the database, but the type module Right now, Ecto doesn't allow to define somehow configurable custom types, so calecto should define a custom type for each time zone, or, surely preferable, implement some macro to define them dynamically (I'm not still quite skilled in Elixir metaprogramming, but I guess it should be possible, isn't it?). By the way, is there any reason why, being postgres specific, Thanks! |
Hi This is why "timestamp with time zone" is not used:
The name is misleading. It does not really store the time zone. Here is some more information about why it is necessary to save the local "wall time" instead of UTC: http://www.creativedeletion.com/2015/03/19/persisting_future_datetimes.html |
Thanks for the response. I read the article and now it makes sense 👍 |
I am a little confused on how to manage dates my phoenix app when my DB is on UTC and most (but not all) my users edit dates in a specific timezone (that is not UTC).
I posted my question to Elixir Forum (https://elixirforum.com/t/confused-with-storing-dates-with-calendar-ecto/2162) and José suggested create a PR for
Calecto.DateTimeUTC.cast
to accept a non "etc/utc" timezone and convert it to utc.What are your thoughts on this?
Thanks in advance.
The text was updated successfully, but these errors were encountered: