Skip to content

Commit

Permalink
Make created_at timezone conversion consistent with ActiveRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
erikrozendaal committed Feb 8, 2024
1 parent 5bf040a commit 6beb1e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/sequent/core/event_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ def store_events(command, streams_with_events = [])
uncommitted_events.map do |event|
r = Sequent::Core::Oj.strict_load(Sequent::Core::Oj.dump(event))
# Since ActiveRecord uses `TIMESTAMP WITHOUT TIME ZONE`
# we need to manually convert database timestamps to UTC
# on serialization
r['created_at'] = event.created_at.to_time.utc
# we need to manually convert database timestamps to the
# ActiveRecord default time zone on serialization.
r['created_at'] = ActiveRecord.default_timezone == :utc ? event.created_at.to_time.getutc : event.created_at.to_time.getlocal
r['event_type'] = event.class.name
r
end,
Expand Down

0 comments on commit 6beb1e8

Please sign in to comment.