demarches-normaliennes/app/components/editable_champ/datetime_component.rb

14 lines
307 B
Ruby
Raw Normal View History

2022-08-12 10:45:04 +02:00
class EditableChamp::DatetimeComponent < ApplicationComponent
def initialize(form:, champ:)
@form, @champ = form, champ
end
def datetime_start_year(date)
if date == nil || date.year == 0 || date.year >= Date.today.year - 1
Date.today.year - 1
else
date.year
end
end
end