Fix time zone problem.

This commit is contained in:
BoHung Chiu 2020-08-04 14:48:46 +08:00
parent c4883d495b
commit 2656b83ae8
2 changed files with 3 additions and 3 deletions

View File

@ -24,6 +24,6 @@ class EPaperTopic
end
def criteria_title
PaperCriteria.where(:start_date.lte => self.period, :end_date.gte => self.period).first.title rescue ""
PaperCriteria.where(:start_date.lte => self.period.in_time_zone(Time.zone.utc_offset / 3600), :end_date.gte => self.period.in_time_zone(Time.zone.utc_offset / 3600)).first.title rescue ""
end
end

View File

@ -16,8 +16,8 @@ class PaperCriteria
def epaper_topics
tmp = EPaperTopic.where(:period.gte => self.start_date, :period.lte => self.end_date).can_display
tmp = EPaperTopic.where(:period.gte => self.start_date, :period.lte => self.end_date).limit(1) if tmp.first.nil?
tmp = EPaperTopic.where(:period.gte => self.start_date.in_time_zone(Time.zone.utc_offset / 3600), :period.lte => self.end_date.in_time_zone(Time.zone.utc_offset / 3600)).can_display
tmp = EPaperTopic.where(:period.gte => self.start_date.in_time_zone(Time.zone.utc_offset / 3600), :period.lte => self.end_date.in_time_zone(Time.zone.utc_offset / 3600)).limit(1) if tmp.first.nil?
tmp
end