1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

(bug) change event date with wrong timezone

This commit is contained in:
Du Peng 2023-02-13 11:39:36 +01:00
parent 8369a66c7c
commit e5eb24a9dc

View File

@ -33,17 +33,16 @@ class EventService
end end
def date_range(starting, ending, all_day) def date_range(starting, ending, all_day)
start_date = Time.zone.parse(starting[:date]) start_date = Date.parse(starting[:date])
end_date = Time.zone.parse(ending[:date]) end_date = Date.parse(ending[:date])
start_time = starting[:time] ? Time.zone.parse(starting[:time]) : nil start_time = starting[:time] ? Time.zone.parse(starting[:time]) : nil
end_time = ending[:time] ? Time.zone.parse(ending[:time]) : nil end_time = ending[:time] ? Time.zone.parse(ending[:time]) : nil
if all_day || start_time.nil? || end_time.nil? if all_day || start_time.nil? || end_time.nil?
start_at = DateTime.new(start_date.year, start_date.month, start_date.day, 0, 0, 0, start_date.zone) start_at = Time.zone.local(start_date.year, start_date.month, start_date.day, 0, 0, 0)
end_at = DateTime.new(end_date.year, end_date.month, end_date.day, 23, 59, 59, end_date.zone) end_at = Time.zone.local(end_date.year, end_date.month, end_date.day, 23, 59, 59)
else else
start_at = DateTime.new(start_date.year, start_date.month, start_date.day, start_time.hour, start_time.min, start_time.sec, start_at = Time.zone.local(start_date.year, start_date.month, start_date.day, start_time.hour, start_time.min, start_time.sec)
start_date.zone) end_at = Time.zone.local(end_date.year, end_date.month, end_date.day, end_time.hour, end_time.min, end_time.sec)
end_at = DateTime.new(end_date.year, end_date.month, end_date.day, end_time.hour, end_time.min, end_time.sec, end_date.zone)
end end
{ start_at: start_at, end_at: end_at } { start_at: start_at, end_at: end_at }
end end