Set date format in ruby model (sinatra/datamapper)

Posted by Gearóid on Stack Overflow See other posts from Stack Overflow or by Gearóid
Published on 2010-06-03T08:20:27Z Indexed on 2010/06/03 8:24 UTC
Read the original article Hit count: 254

Filed under:
|
|
|

Hi,

I have a ruby model that contains a date attribue which I'd like to be able to pass in as a parameter in the format dd/MM/yyyy.

However, my sqlite3 db stores the data in yyyy-MM-dd format so when a date like 20/10/2010 gets passed in, it will not be read to the database.

I am using the Sinatra framework and using haml for the markup creation.

Do I need to write a helper that takes the date string and converts it to the correct format for the db? Or can I set a format type on the models attribute?

Thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about date