Google 日历 API(v2)中与时间相关的查询需要采用 RFC3339 格式。当我使用 'require "time"' 导入 Time 类后,却没有找到 rfc3339 方法。
Google 日历 API(v2)中与时间相关的查询需要采用 RFC3339 格式。当我使用 'require "time"' 导入 Time 类后,却没有找到 rfc3339 方法。
to_datetime
方法将时间转换为DateTime
对象。Time.now.to_datetime.rfc3339 #=> "2014-11-06T10:40:54+11:00"
请参见:
http://www.ruby-doc.org/stdlib-2.4.1/libdoc/date/rdoc/Time.html。
Time.now.utc.strftime('%FT%TZ')
#=> "2013-08-15T06:13:28Z"
,这非常适合于HTML5中的type='datetime'
输入字段。这有帮助吗?http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/DateTime.html#method-i-rfc3339
这个链接提供了关于DateTime类中rfc3339方法的文档。DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9)
#=> "2001-02-03T04:05:06.123456789+07:00"
Date.today.next.to_time.to_datetime.to_s.gsub('+','%2B')
。这看起来很像JavaScript的方法链。嗯。 - taro