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)
=> #<Date: 4908563/2,0,2299161>
d2 = d1 >> 1
=> #<Date: 4908623/2,0,2299161>
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
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.