本文简要介绍ruby语言中 Time.httpdate
的用法。
用法
httpdate(date)
将 date
解析为 RFC 2616 定义的 HTTP-date 并将其转换为 Time
对象。
如果 date
不符合 RFC 2616 或 Time
类不能表示指定的日期,则会引发 ArgumentError
。
有关此格式的更多信息,请参阅 httpdate
。
require 'time'
Time.httpdate("Thu, 06 Oct 2011 02:26:12 GMT")
#=> 2011-10-06 02:26:12 UTC
您必须要求 ‘time’ 才能使用此方法。
相关用法
- Ruby Time.hour用法及代码示例
- Ruby Time.gmtime用法及代码示例
- Ruby Time.at用法及代码示例
- Ruby Time.utc_offset用法及代码示例
- Ruby Time.isdst用法及代码示例
- Ruby Time.time + numeric用法及代码示例
- Ruby Time.wednesday?用法及代码示例
- Ruby Time.localtime用法及代码示例
- Ruby Time.yday用法及代码示例
- Ruby Time.time <=>用法及代码示例
- Ruby Time.month用法及代码示例
- Ruby Time.utc?用法及代码示例
- Ruby Time.new用法及代码示例
- Ruby Time.monday?用法及代码示例
- Ruby Time.getutc用法及代码示例
- Ruby Time.round用法及代码示例
- Ruby Time.dst?用法及代码示例
- Ruby Time.tv_nsec用法及代码示例
- Ruby Time.xmlschema用法及代码示例
- Ruby Time.gmt?用法及代码示例
- Ruby Time.to_r用法及代码示例
- Ruby Time.gmt_offset用法及代码示例
- Ruby Time.ceil用法及代码示例
- Ruby Time.parse用法及代码示例
- Ruby Time.thursday?用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Time.httpdate。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。