[feat]Properly add timezone to events starttime and endtime; set now to be the time in conference timezone instead of the user s time zone in fullcalendar

This commit is contained in:
Jimmy 2021-05-01 01:37:52 +08:00 committed by CactusPuppy
parent 03b12eafb0
commit 6777ffb0bb
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
6 changed files with 25 additions and 9 deletions

View file

@ -133,6 +133,14 @@ class EventSchedule < ApplicationRecord
other.schedule_id == schedule_id
end
def start_time_in_conference_timezone
time_in_conference_timezone(start_time)
end
def end_time_in_conference_timezone
time_in_conference_timezone(end_time)
end
private
def replaced_event_schedules
@ -187,4 +195,10 @@ class EventSchedule < ApplicationRecord
errors.add(:schedule, "must be one of #{event.track.name} track's schedules") unless event.track.schedules.include?(schedule)
end
def time_in_conference_timezone(time)
time_in_tz = time.in_time_zone(timezone)
time_in_tz -= time_in_tz.utc_offset
time_in_tz
end
end