Trying to use DateTime::strptime to convert date/time strings. The
"month" format string returns "Invalid Date" for almost every
combination of input string and format string, including some
combinations that absolutely should work. I started with full date/time
strings but because of the errors I've tried to isolate the problem down
to just the "month" component. I have not tried "day" or "hour".
How do I verify this as a defect?
If it is, what is next step? Thx in advance.
Here is Ruby version info and results of the attached script:
C:\Users\pt\Documents\Source\rb>ruby -v
ruby 2.0.0p195 (2013-05-14) [i386-mingw32]
C:\Users\pt\Documents\Source\rb>ruby DateTime_strptime_problem.rb
DateTime.strptime( '01' , '%m' ) :: month fmt string ZERO-padded
{SHOULD PASS} --> #<DateTime: 2013-01-01T00:00:00+00:00
((2456294j,0s,0n),+0s,2299161j)>
DateTime.strptime( '01' , '%_m' ) :: month fmt string blank-padded -->
invalid date
DateTime.strptime( '01' , '%-m' ) :: month fmt string unpadded -->
invalid date
DateTime.strptime( ' 1' , '%m' ) :: month fmt string ZERO-padded -->
invalid date
DateTime.strptime( ' 1' , '%_m' ) :: month fmt string blank-padded
{SHOULD PASS} --> invalid date
DateTime.strptime( ' 1' , '%-m' ) :: month fmt string unpadded -->
invalid date
DateTime.strptime( '1' , '%m' ) :: month fmt string ZERO-padded -->
#<DateTime: 2013-01-01T00:00:00+00:00 ((2456294j,0s,0n),+0s,2299161j)>
DateTime.strptime( '1' , '%_m' ) :: month fmt string blank-padded -->
invalid date
DateTime.strptime( '1' , '%-m' ) :: month fmt string unpadded {SHOULD
PASS} --> invalid date
DateTime.strptime( '011' , '%m' ) :: month fmt string ZERO-padded
{SHOULD PASS} --> #<DateTime: 2013-01-01T00:00:00+00:00
((2456294j,0s,0n),+0s,2299161j)>
DateTime.strptime( '011' , '%_m' ) :: month fmt string blank-padded -->
invalid date
DateTime.strptime( '011' , '%-m' ) :: month fmt string unpadded -->
invalid date
DateTime.strptime( ' 11' , '%m' ) :: month fmt string ZERO-padded -->
invalid date
DateTime.strptime( ' 11' , '%_m' ) :: month fmt string blank-padded
{SHOULD PASS} --> invalid date
DateTime.strptime( ' 11' , '%-m' ) :: month fmt string unpadded -->
invalid date
DateTime.strptime( '11' , '%m' ) :: month fmt string ZERO-padded -->
#<DateTime: 2013-11-01T00:00:00+00:00 ((2456598j,0s,0n),+0s,2299161j)>
DateTime.strptime( '11' , '%_m' ) :: month fmt string blank-padded -->
invalid date
DateTime.strptime( '11' , '%-m' ) :: month fmt string unpadded {SHOULD
PASS} --> invalid date
Attachments:
http://www.ruby-forum.com/attachment/8717/DateTime_strptime_problem.rb
···
--
Posted via http://www.ruby-forum.com/.