I am trying to parse a weekly string that HTML5 input with the type of "week" may return to the actual date or time in ruby.
Input will return a string like this: "2014-W05", where W05 is the fifth week of the year.
Here is what I tried:
2.1.0dev :057 > Time.strptime("2014-W05", "%Y-W%V")
2014-01-01 00:00:00 -0800
2.1.0dev :058 > Date.strptime("2014-W05", "%Y-W%V")
2014-01-01
2.1.0dev :058 > DateTime.strptime("2014-W05", "%Y-W%V")
Wed, 01 Jan 2014 00:00:00 +0000
According to the documentation: http://apidock.com/ruby/DateTime/strftime
% V - week week number (01..53)
Thank you for your help!
source
share