I am using Time.parse to create a Time object from a string.
For some reason
Time.parse("05-14-2009 19:00")
causes an argument our of range error, whereas
Time.parse("05-07-2009 19:00")
does not
Any ideas?
I am using Time.parse to create a Time object from a string.
For some reason
Time.parse("05-14-2009 19:00")
causes an argument our of range error, whereas
Time.parse("05-07-2009 19:00")
does not
Any ideas?
My guess would be that its expecting the second part of the string (the 14) to be the month.
It is probably expecting Day-Month-Year format, so your first value is trying to specify the 5th day of the 14th month.
It's beacuse of the heuristics of Time#parse.
And it's due to anglo-american formats.
With dashes '-' it expects mm-dd-yyyy, with slashes '/' it expects dd/mm/yyyy
This behaivour CHANGES intentionally in 1.9. to accomplish eur,iso and jp Date standadrs
You probably do not need it to solve this problem but I still recommend checking out the natural language date/time parser Chronic, it has saved me a lot of work a couple of times.