Fullcalendar时区

时间:2012-12-10 16:43:39

标签: ruby-on-rails fullcalendar

我有一个使用Fullcalendar的RoR应用程序 - 在Heroku上运行。 日历视图显示事件为上午9点至上午10点。当我查看时间列表时,我得到4p - 7pm。

是否与时区有关?

我尝试将ignoreTimeZone设置为true,然后设置为false:

$(document).ready ->
  $('#calendar').fullCalendar
    editable: true,
    ignoreTimezone: true,
    header:
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    defaultView: 'month',
    height: 500,
    slotMinutes: 30,

感谢您的帮助!

以下是一个示例 - 数据库记录的start_at为16:00(下午4点),但Fullcallendar视图显示从上午9点开始

2 个答案:

答案 0 :(得分:0)

您的事件列表(index.html.erb等)显示UTC时间,而fullcalendar显示浏览器检测到的时区中的时间。

为了解决这个问题,您应该将每个请求线程的时区设置为用户的时区。这应该有效:

在您的事件控制器中,添加以下内容:

before_filter set_time_zone

def set_time_zone
    (...)
end

查看此帖子中的其余代码: https://stackoverflow.com/a/942865/336806

我也在使用这个整洁的宝石:

https://github.com/scottwater/detect_timezone_rails

答案 1 :(得分:0)

以下解决了问题:

$ heroku config:添加TZ = America / Denver

相关问题