parent
eaf462fe45
commit
3cd649e59b
|
|
@ -1016,12 +1016,21 @@ class EventNewsModsController < ApplicationController
|
|||
page = Page.where(:module => "event_news_mod").first
|
||||
read_more_url_root = "/#{I18n.locale.to_s + page.url}" rescue ""
|
||||
end
|
||||
if params[:unix_start].present? && params[:unix_end].present?
|
||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
||||
events = []
|
||||
max_unix_time = 253402300799 # 對應西元 9999-12-31,超過這個範圍視為不合法輸入,避免 Time.at 收到超大整數噴 RangeError
|
||||
unix_start = params[:unix_start].to_i
|
||||
unix_end = params[:unix_end].to_i
|
||||
month_start = params[:month_start].to_i
|
||||
|
||||
if params[:unix_start].present? && params[:unix_end].present? &&
|
||||
unix_start.between?(0, max_unix_time) && unix_end.between?(0, max_unix_time)
|
||||
agenda_start = Time.at(unix_start).utc.to_s
|
||||
agenda_end = Time.at(unix_end).utc.to_s
|
||||
events = EventNews.agenda_events(agenda_start,agenda_end,read_more_url_root)
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
|
||||
calendar_time = month_start.between?(0, max_unix_time) ? Time.at(month_start).utc : Time.now.utc
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(calendar_time)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1030,4 +1039,4 @@ class EventNewsModsController < ApplicationController
|
|||
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("event_news.month_name.#{now_date.month}")
|
||||
I18n.t("event_news.calendar_title",year: now_date.year,month: month_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue