2019-08-08 18:28:23 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-07 21:35:37 +00:00
|
|
|
# Maneja la fecha del document
|
2023-10-06 14:52:42 +00:00
|
|
|
class MetadataDocumentDate < MetadataDate
|
2019-08-07 21:35:37 +00:00
|
|
|
# La fecha por defecto es ahora!
|
2023-10-06 14:52:42 +00:00
|
|
|
#
|
|
|
|
# @return [Time]
|
2019-08-07 21:35:37 +00:00
|
|
|
def default_value
|
2023-10-06 14:52:42 +00:00
|
|
|
super.to_time
|
2019-08-07 21:35:37 +00:00
|
|
|
end
|
|
|
|
|
2023-10-06 14:52:42 +00:00
|
|
|
# @return [Time,nil]
|
2021-06-16 14:35:37 +00:00
|
|
|
def document_value
|
2023-10-06 14:52:42 +00:00
|
|
|
document.data['date']
|
2021-05-06 15:33:28 +00:00
|
|
|
end
|
|
|
|
|
2021-05-13 15:52:49 +00:00
|
|
|
# Siempre es obligatorio
|
|
|
|
def required
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2019-08-13 23:33:57 +00:00
|
|
|
|
2023-10-06 14:52:42 +00:00
|
|
|
# Las fechas de los Jekyll::Document se manejan con Time pero no nos
|
|
|
|
# importa la hora.
|
|
|
|
#
|
|
|
|
# @param :value [Any]
|
|
|
|
# @return [Time, nil]
|
|
|
|
def sanitize(value)
|
|
|
|
super(value.to_s.split(' ', 2).first)&.to_time
|
2019-08-13 23:33:57 +00:00
|
|
|
end
|
2019-08-07 21:35:37 +00:00
|
|
|
end
|