Skip to content
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

datetime doesn't properly preserve zone #153

Closed
mockdeep opened this issue Aug 23, 2022 · 4 comments · Fixed by #155
Closed

datetime doesn't properly preserve zone #153

mockdeep opened this issue Aug 23, 2022 · 4 comments · Fixed by #155
Labels

Comments

@mockdeep
Copy link

When we configure Time.zone in our application to something different than UTC, jsonb_accessor does not properly deserialize the timestamp. For example:

Time.zone = "America/Los_Angeles"
Time.zone.now # => Tue, 23 Aug 2022 15:20:14.000000000 PDT -07:00
user = User.new(onboarded_at: Time.zone.now) 
user.onboarded_at # => Tue, 23 Aug 2022 15:20:14.000000000 PDT -07:00
user.save!
user.onboarded_at # => Tue, 23 Aug 2022 15:20:14.000000000 PDT -07:00
user.reload
user.onboarded_at # => Tue, 23 Aug 2022 22:20:14.000000000 PDT -07:00
                                       ^^^^^^^^^^^^^^^^^^^^^^^^ shifted by 7 hours after a reload
@mockdeep
Copy link
Author

I notice in the code you respect the configured ActiveRecord::Base.default_timezone, but we're not looking to change the stored zone from UTC, only the in-memory zone the user sees.

@haffla
Copy link
Contributor

haffla commented Sep 18, 2022

Sorry for the late reply @mockdeep. I was able to reproduce this. I've created a PR that should fix the issue.

@haffla
Copy link
Contributor

haffla commented Sep 23, 2022

@mockdeep I have just released version 1.3.6 which fixes the issue.

@mockdeep
Copy link
Author

@haffla great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants