[fix] Fix time displayed in happening_now.haml; Make event_schedule#happening_now? more efficient

This commit is contained in:
Jimmy 2021-03-19 17:13:34 +08:00
parent cab293e947
commit 1c54d38094
2 changed files with 3 additions and 2 deletions

View file

@ -55,9 +55,10 @@ class EventSchedule < ApplicationRecord
# True within `threshold` before and after the event. # True within `threshold` before and after the event.
# #
def happening_now?(threshold = 30.minutes) def happening_now?(threshold = 30.minutes)
return false if end_time < Time.now
event_time_range = start_time..end_time event_time_range = start_time..end_time
now_range = (Time.now - threshold)..(Time.now + threshold) now_range = (Time.now - threshold)..(Time.now + threshold)
event_time_range.overlaps?(now_range) && (end_time > Time.now) event_time_range.overlaps?(now_range)
end end
def self.withdrawn_or_canceled_event_schedules(schedule_ids) def self.withdrawn_or_canceled_event_schedules(schedule_ids)

View file

@ -12,7 +12,7 @@
%h3 %h3
This page was loaded at This page was loaded at
= inyourtz(Time.now) do = inyourtz(Time.now) do
Time.now.strftime('%a %b %d at %I:%M %P (%z)').to_s #{Time.now.strftime('%a %b %d at %I:%M %P (%z)').to_s}
.row .row
/ TODO: Clean this up, merge with all events page. / TODO: Clean this up, merge with all events page.