pejmanjohn
pejmanjohn

Reputation: 1057

Date format bug when date is in Portuguese?

I'm seeing some odd behavior in our application coming from a user working in what I believe to be Portuguese.

I realized that Rails seems to be mis-interpreting the dates she is submitting. Here's some examples:

Date.parse("ter, 30 abr 2013 07:00:00 GMT-07:00")
=> Thu, 30 May 2013

Date.parse("dom, 5 mai 2013 07:00:00 GMT-07:00 -07:00")
ArgumentError: invalid date

Is there something extra I need to do correctly identify dates being submitted in other languages?

Upvotes: 0

Views: 386

Answers (1)

katzmopolitan
katzmopolitan

Reputation: 1381

Date are parsed with Ruby Date class with the following documentation

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-c-parse

I'm not sure it's a great idea to allow your users to type in the full date by themselves - they can mistype or assume different format. I suggest to use datepicker that with localized presentation based on the users location? One of the the many date pickers that allow this is http://docs.jquery.com/UI/Datepicker/Localization

Upvotes: 1

Related Questions