From b34ff7be7aa828a256056571f20668a04491207c Mon Sep 17 00:00:00 2001 From: Nathan Ehresman Date: Fri, 13 Dec 2024 16:10:39 -0500 Subject: [PATCH] preserve the timezone of time_object with ActiveSupport >= 7.2 --- lib/icalendar/recurrence/time_util.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/icalendar/recurrence/time_util.rb b/lib/icalendar/recurrence/time_util.rb index b14391c..ec81d82 100644 --- a/lib/icalendar/recurrence/time_util.rb +++ b/lib/icalendar/recurrence/time_util.rb @@ -26,7 +26,12 @@ def to_time(time_object, options = {}) if supported_time_object?(time_object) time_object elsif supported_icalendar_object?(time_object) - time_object.value + if !defined?(ActiveSupport) || Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new('7.2') + time_object.value + else + # Preserve the timezone of the time_object + time_object.value.to_time.in_time_zone(time_object.value.time_zone) + end elsif supported_datetime_object?(time_object) datetime_to_time(time_object, options) elsif supported_date_object?(time_object)