2018-02-13 18:18:20 +01:00
|
|
|
class Champs::DateChamp < Champ
|
2018-06-14 17:41:31 +02:00
|
|
|
before_save :format_before_save
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def format_before_save
|
|
|
|
self.value =
|
|
|
|
begin
|
|
|
|
Date.parse(value).iso8601
|
|
|
|
rescue
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
2018-06-15 13:47:32 +02:00
|
|
|
|
|
|
|
def string_value
|
|
|
|
Date.parse(value).strftime('%d/%m/%Y')
|
|
|
|
end
|
2018-02-13 18:18:20 +01:00
|
|
|
end
|