scinote-web/app/models/repository_date_value.rb

23 lines
466 B
Ruby
Raw Normal View History

2019-12-06 19:50:19 +08:00
# frozen_string_literal: true
class RepositoryDateValue < RepositoryDateTimeValueBase
PRELOAD_INCLUDE = :repository_date_value
def data_changed?(new_data)
2019-12-10 20:39:08 +08:00
new_time = Time.zone.parse(new_data)
new_time.to_date != data.to_date
end
2019-12-10 20:39:08 +08:00
def formatted
super(:full_date)
end
def self.new_with_payload(payload, attributes)
value = new(attributes)
value.data = Time.zone.parse(payload)
value
end
2020-01-10 16:29:20 +08:00
alias export_formatted formatted
2019-12-06 19:50:19 +08:00
end