J
Johan Allard
Hi all,
I live in australia in in Australia dates are written as DD/MM/YYYY. In
the database, the dates are stored as YYYY-MM-DD. I want to use the
before_validation function and check if #{(\d+)/(\d+)/(\d+)} and then
convert to the correct iso date format.
The problem is that when the before_validation function kicks in, the
date variable is now a Date object. It is no longer a string, and it
has been formatted using the american MM/DD/YYYY format to YYYY-MM-DD.
Since it is a date object, it is not possible to check how the date was
formatted.
Currently I run the check in the controller and to keep the model
intact it would be fantastic if there was a way of doing this in the
before_validation function (or similar) instead.
Thank you
//johan
I live in australia in in Australia dates are written as DD/MM/YYYY. In
the database, the dates are stored as YYYY-MM-DD. I want to use the
before_validation function and check if #{(\d+)/(\d+)/(\d+)} and then
convert to the correct iso date format.
The problem is that when the before_validation function kicks in, the
date variable is now a Date object. It is no longer a string, and it
has been formatted using the american MM/DD/YYYY format to YYYY-MM-DD.
Since it is a date object, it is not possible to check how the date was
formatted.
Currently I run the check in the controller and to keep the model
intact it would be fantastic if there was a way of doing this in the
before_validation function (or similar) instead.
Thank you
//johan