-
Notifications
You must be signed in to change notification settings - Fork 68
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
RFC: Force conversion to/from a specific timezone #47
Comments
I have implemented such behaviour in my fork (hard-coded for the time being: phillipp@475d0be). Would you like to integrate that? In that case, I'm not so sure what the best implementation would be. I thought about an extra type (like Timex.Ecto.LocalDateTime or sth.) but 99% of the module would be exactly the same code than the DateTime type. Can you think of a better way? I'm new to elixir and haven't fully grasped all the patterns that are possible and when to use what. |
Probably the best way is to implement a Timex.Ecto.NaiveDateTime type which performs no conversions. Inputs will be converted to NaiveDateTime, and outputs will always be NaiveDateTime. |
It's implementation can be very similar to Timex.Ecto.DateTime, just without the conversions to/from UTC. |
I will put this on my TODO list, but it may be a week or two before I can get to it, if you'd like to take a stab at it and open a PR to collaborate on, I'd be glad to help with any questions. |
I have now tested two implementations: a) one that converts the time from/to the local timezone, and that worked as I expected At least for my use case I would need the first implementation. I'm not sure if that is a extremely specific case, but coming from Rails I wanted to match this behaviour:
What do you think, is that too application-specific and should be part of my app or might there be a use case that should be supported by the lib? I think both might be possible... |
Sorry it took me so long to get back to this - I am open to support such configuration, but I would suggest proposing it to the Ecto team first - it would be far better if it was an upstream config option, but if it's something they are not prepared to do in Ecto, I would be open to a PR for this project :) |
Hi,
I'm maintaining a legacy app where the time zones are stored in the local time zone instead of UTC. I want to access the database via ecto. The problem is that it messes up the time by converting it to/from UTC and so everything breaks (there are literally hundreds of other clients that use the same database).
What is the best way to turn off the time zone conversion?
The text was updated successfully, but these errors were encountered: