datetime - How can I parse a date in Rails without a month or a day? -


i need parse date in rails json string possibly provided without month or day, , return in iso8601 format. if day not provided, need return first of month of year, , if month not provided, first of year.

simply running datetime.parse(response['date']).utc.iso8601 throws argumenterror when month or day missing, such datetime.parse('2001').

datetime handles exact conditions beautifully datetime.new optional integer parameters, how can best handle when parsing string?

i have keep i18n in mind when doing this, while store 3 diferent formatted string args strptime each locale, seems hacky. if indeed best way handle this, i'd love explanation.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -