From: Dan Daniels Date: 2007-08-01T07:55:00+09:00 Subject: Re: help with string matching >> Would Time#strftime be better? > > Easier to read, I think. Or if you're using a Date object, you could > use Date#strftime. It also looks like you're adding a month to > @calendar1, which is easy with a Date object: > >>> d1 = Date.civil(2007,06,30) > => # > >>> d1.strftime('%Y-%m-%d') > => "2007-06-30" > >>> d2 = d1 >> 1 > => # > >>> d2.strftime('%Y-%m-%d') > => "2007-07-30" I see. Also easier to imagine the output when you call it as %Y-%m-%d. @calendar1 is a gtk calendar widget, and within ruby calling @calendar1.date returns the date as 2007730, which caused Date.parse to crash as there is only 1 part instead of the expected 3. That is why I used the @calendar1.year @calendar1.month @calendar1.day, but @calendar1.month returns 0 based months, which is why I used @calendar1.month + 1, which works, but looks sloppy. So, how would you parse a date formated as 2007730 into 2007-06-30? I know that I could parse it out manually, but I'm assuming there is a more elegant solution. Thank you for your help. Dan -- Posted via http://www.ruby-forum.com/.