Tuesday, 15 April 2014

Parsing a string to a date in Ruby -


I think that seems like a repeated question but I think this situation is different.

I have a string that has a date in the following format: Thursday, June 20.

I want to parse it on a date variable and then increment it the next day.

I have done so far

  text = "Thursday, June 20" date = date.Sew date = date. StripTime (text, '{% a,% m,% d}')   

But this gives me the following error:

  Invalid date (ArgumentError )   

I found this idea:

The answers I have seen, are still parsing the stars in which there is complete information (the whole month of the week Or day) Am I trying to do as well? If any suggestions about work will be most appreciated

To answer your requirement I would like to parse it in a date variable and then it increments it the next day. I tried the following:

  is required 'date' d = date. From ("गुरु, जून 20") # & gt; # & Lt; Date: 2013-06-20 ((2456464j, 0s, 0n), + 0s, 2299161j) & gt; D.to_s # = & gt; "2013-06-20" d.next.to_s # = & gt; "2013-06-21"    

No comments:

Post a Comment