Correct time zone of API dates

Prior to this change, the API returned incorrect dates in UTC instead of
the conference time zone.
This commit is contained in:
Andrew Kvalheim 2022-09-28 13:22:15 -07:00
parent 397341a324
commit 6ce2e66f14
4 changed files with 24 additions and 8 deletions

View file

@ -3,8 +3,11 @@
class EventScheduleSerializer < ActiveModel::Serializer
include ActionView::Helpers::TextHelper
attribute :start_time, key: :date
attributes :room
attributes :date, :room
def date
object.start_time&.change(zone: object.event.program.conference.timezone)
end
def room
object.room.guid

View file

@ -3,9 +3,11 @@
class EventSerializer < ActiveModel::Serializer
include ActionView::Helpers::TextHelper
attributes :guid, :title, :length
attribute :time, key: :scheduled_date
attributes :language, :abstract, :speaker_ids, :type, :room, :track
attributes :guid, :title, :length, :scheduled_date, :language, :abstract, :speaker_ids, :type, :room, :track
def scheduled_date
object.time&.change(zone: object.program.conference.timezone)
end
def speaker_ids
speakers = object.event_users.select { |i| i.event_role == 'speaker' }