scinote-web/app/models/repository_date_range_value.rb

24 lines
639 B
Ruby
Raw Normal View History

2019-12-06 19:50:19 +08:00
# frozen_string_literal: true
class RepositoryDateRangeValue < RepositoryDateTimeRangeValueBase
def data_changed?(new_data)
2019-12-17 20:42:25 +08:00
data = JSON.parse(new_data).symbolize_keys
st = Time.zone.parse(data[:start_time])
et = Time.zone.parse(data[:end_time])
2019-12-10 20:39:08 +08:00
st.to_date != start_time.to_date || et.to_date != end_time.to_date
end
2019-12-10 20:39:08 +08:00
def formatted
super(:full_date)
end
def self.new_with_payload(payload, attributes)
2019-12-17 20:42:25 +08:00
data = JSON.parse(payload).symbolize_keys
value = new(attributes)
2019-12-17 20:42:25 +08:00
value.start_time = Time.zone.parse(data[:start_time])
value.end_time = Time.zone.parse(data[:end_time])
value
end
2019-12-06 19:50:19 +08:00
end