本文简要介绍ruby语言中  Date.strptime  的用法。
用法
strptime([string='-4712-01-01'[, format='%F'[, start=Date::ITALY]]]) → date
使用给定模板解析给定的日期和时间表示,并创建一个日期对象。与 strftime 不同,strptime 不支持指定标志和宽度。
Date.strptime('2001-02-03', '%Y-%m-%d')   #=> #<Date: 2001-02-03 ...>
Date.strptime('03-02-2001', '%d-%m-%Y')   #=> #<Date: 2001-02-03 ...>
Date.strptime('2001-034', '%Y-%j')        #=> #<Date: 2001-02-03 ...>
Date.strptime('2001-W05-6', '%G-W%V-%u')  #=> #<Date: 2001-02-03 ...>
Date.strptime('2001 04 6', '%Y %U %w')    #=> #<Date: 2001-02-03 ...>
Date.strptime('2001 05 6', '%Y %W %u')    #=> #<Date: 2001-02-03 ...>
Date.strptime('sat3feb01', '%a%d%b%y')    #=> #<Date: 2001-02-03 ...>
另请参见 strptime(3) 和  strftime  。
相关用法
- Ruby Date.strftime用法及代码示例
 - Ruby Date.step用法及代码示例
 - Ruby Date.start用法及代码示例
 - Ruby Date.valid_civil?用法及代码示例
 - Ruby Date.gregorian?用法及代码示例
 - Ruby Date.valid_ordinal?用法及代码示例
 - Ruby Date.leap?用法及代码示例
 - Ruby Date.today用法及代码示例
 - Ruby Date.mday用法及代码示例
 - Ruby Date.next_year用法及代码示例
 - Ruby Date.day用法及代码示例
 - Ruby Date.d ===用法及代码示例
 - Ruby Date.to_s用法及代码示例
 - Ruby Date.parse用法及代码示例
 - Ruby Date.civil用法及代码示例
 - Ruby Date.cwyear用法及代码示例
 - Ruby Date.yday用法及代码示例
 - Ruby Date.d + other用法及代码示例
 - Ruby Date.julian?用法及代码示例
 - Ruby Date._parse用法及代码示例
 - Ruby Date.prev_year用法及代码示例
 - Ruby Date.jisx0301用法及代码示例
 - Ruby Date.new_start用法及代码示例
 - Ruby Date.amjd用法及代码示例
 - Ruby Date.mon用法及代码示例
 
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Date.strptime。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
