diff --git a/app/models/metadata_document_date.rb b/app/models/metadata_document_date.rb index bd46c5a..f49aaa7 100644 --- a/app/models/metadata_document_date.rb +++ b/app/models/metadata_document_date.rb @@ -10,13 +10,12 @@ class MetadataDocumentDate < MetadataTemplate # El valor puede ser un Date, Time o una String en el formato # "yyyy-mm-dd" def value - return self[:value] if self[:value].is_a? Date - return self[:value] if self[:value].is_a? Time + return self[:value] = document.date || default_value if self[:value].nil? - begin - self[:value] = Date.parse(self[:value]).to_time - rescue ArgumentError, TypeError - document.date || default_value + if self[:value].is_a? String + self[:value] = Date.iso8601(self[:value]).to_time end + + self[:value] end end