【问题标题】:FullCalendar Events not showing up only on SafariFullCalendar 事件仅在 Safari 上不显示
【发布时间】:2012-02-02 10:23:02
【问题描述】:

我已经使用 FullCalendar 插件有一段时间了,我已经设法让它在 FF 和 Chrome 中工作,但我似乎无法理解为什么这些事件没有出现在 Safari 上。

我正在使用 Rails 后端将事件作为数组获取。这是 FireBug 显示的事件的 JSON 对象。

_end: Invalid Date    
_id: "1953"   
_start: Fri Feb 10 2012 00:00:00 GMT+0530 (IST)  
allDay: false  
backgroundColor: "#F60 !important"  
className: Array[0]  
color: "#FFFFFF !important"  
description: ""  
end: Invalid Date  
start: Fri Feb 10 2012 00:00:00 GMT+0530 (IST)   
textColor: "#FFFFFF !important"   
__proto__: Object   

我在 Safari 控制台上没有错误。无效的结束日期在 FF 和 Chrome 上显示为 null

这是我填充事件的方式

event[:id]                        = each_event.id    
event[:title]                = each_event.event_title    
event[:allDay]               = each_event.all_day?   
event[:start]                = each_event.start_time.strftime('%Y-%m-%d %H:%M:00')    
event[:end] = each_event.end_date.to_time.strftime('%Y-%m-%d %H:%M:00') if each_event.end_date.present?          
event[:color]                = '#FFFFFF !important'      
event[:backgroundColor]      = (each_event.user ==  current_user) ? '#F60 !important' : '#090 !important'          
event[:backgroundColor]      = '#090 !important' unless each_event.private?       
event[:textColor]            = '#FFFFFF !important'   

我也尝试将日期时间转换为 iso8601 格式,但没有成功。我完全不知道问题是什么。非常感谢您的帮助。

【问题讨论】:

  • 这里有同样的问题。你有没有设法解决这个问题?
  • 我使用 fullCalendar 已经有一段时间了,到目前为止,我在 Safari 上遇到的所有问题都是日期的解析方式有所不同。例如,(Mac 上的 Safari 6.0(7536.25)) -- new Date('01-01-2000') 是无效的,而在其他浏览器中它是完全有效的。在这些情况下,您应该用正斜杠替换所有连字符,因此结果类似于 new Date('01/01/2000')。我希望这会有所帮助。
  • @TomReznik 就我而言,是字符串,这个问题让我找到了正确的位置。但这不是破折号与斜线的问题,在我的情况下,它与破折号完美配合。相反,它是当天的格式,我输出的是一个数字(2012-11-1),而缺少的前导 0 是它被抛弃的原因。我猜这个错误在接近年底的时候会更频繁地遇到,我敢肯定这个月也会遇到同样的错误,但在 10 月和 11 月没有注意到。

标签: jquery ruby-on-rails safari fullcalendar


【解决方案1】:

我遇到了类似的问题。 帮助我的是使用 DateTime 的 .iso8601 函数:

event[:start] = each_event.start_time.iso8601
event[:end] = each_event.end_date.to_time.iso8601 if each_event.end_date.present?

iso8601 格式给出如下输出:2017-01-25T16:15:49+01:00

【讨论】:

  • 老问题,但这个答案似乎不错。从 rfc822 更改为 iso8601 对我有用。
【解决方案2】:

您的字符串格式不正确。

而不是使用

event[:start] = each_event.start_time.strftime('%Y-%m-%d %H:%M:00')
event[:end] = each_event.end_date.to_time.strftime('%Y-%m-%d %H:%M:00') if each_event.end_date.present?

尝试使用

event[:start] = each_event.start_time.to_json
event[:end] = each_event.end_date.to_time.to_json if each_event.end_date.present?

根据 FullCalendar 文档,开始和结束属性需要日期对象或 IETF 格式、ISO8601 格式或 UNIX 时间戳的字符串。因为strftime('%Y-%m-%d %H:%M:00') 不是这些,所以代码不起作用。

http://arshaw.com/fullcalendar/docs/event_data/Event_Object/

【讨论】:

    【解决方案3】:

    我遇到了类似的问题。我从以下位置切换了日期格式:

    “2019-05-09 04:00:00”

    “2019-05-09T04:00:00”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      相关资源
      最近更新 更多