fix for time zones

This commit is contained in:
Harry Bomrah 2014-12-17 18:25:53 +08:00
parent 8f869c8e4d
commit 3194764c46
3 changed files with 9 additions and 7 deletions

View File

@ -285,11 +285,13 @@ var AgendaView = function(calendar){
var eventsManager = function(){ var eventsManager = function(){
var url = "/xhr/calendars/agenda", var url = "/xhr/calendars/agenda",
sd = new Date(start_year,start_month,1), sd = new Date(start_year,start_month,1),
ed = new Date(end_year,end_month+1,0); ed = new Date(end_year,end_month+1,0),
usd = Math.round(sd/1000),
ued = Math.round(ed/1000);
$.ajax({ $.ajax({
type : "get", type : "get",
url : url, url : url,
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"page_id" : _calendar.page_id}, data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"page_id" : _calendar.page_id,"unix_start":usd,"unix_end":ued},
success : function(events){ success : function(events){
$.each(events,function(i,e){ $.each(events,function(i,e){
var ed = eventDom(e), var ed = eventDom(e),

View File

@ -34,8 +34,8 @@ class Admin::CalendarsController < OrbitAdminController
end end
def agenda def agenda
agenda_start = Date.strptime(params[:agenda_start], '%m/%d/%Y') agenda_start = Time.at(params[:unix_start].to_i).to_s
agenda_end = Date.strptime(params[:agenda_end], '%m/%d/%Y') agenda_end = Time.at(params[:unix_end].to_i).to_s
@events = Event.agenda_events(agenda_start,agenda_end) @events = Event.agenda_events(agenda_start,agenda_end)
# re = Event.recurring_event(Time.at(params[:unix_start].to_i), Time.at(params[:unix_end].to_i)) # re = Event.recurring_event(Time.at(params[:unix_start].to_i), Time.at(params[:unix_end].to_i))
# @events = @events.inject(re, :<<) # @events = @events.inject(re, :<<)

View File

@ -45,9 +45,9 @@ class CalendarsController < ApplicationController
else else
calendar_types = CalendarType.where(:category_id.in => categories).collect{|ct| ct.id.to_s } rescue [] calendar_types = CalendarType.where(:category_id.in => categories).collect{|ct| ct.id.to_s } rescue []
end end
if params[:agenda_start].present? && params[:agenda_end].present? if params[:unix_start].present? && params[:unix_end].present?
agenda_start = Date.strptime(params[:agenda_start], '%m/%d/%Y') agenda_start = Time.at(params[:unix_start].to_i).to_s
agenda_end = Date.strptime(params[:agenda_end], '%m/%d/%Y') agenda_end = Time.at(params[:unix_end].to_i).to_s
events = Event.agenda_events(agenda_start,agenda_end).where(:calendar_type_id.in => calendar_types) events = Event.agenda_events(agenda_start,agenda_end).where(:calendar_type_id.in => calendar_types)
end end
end end