Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
664 B

module CollectionTimeHelper
def collection_start_year(date)
window_end_date = Time.zone.local(date.year, 4, 1)
date < window_end_date ? date.year - 1 : date.year
end
def current_collection_start_year
collection_start_year(Time.zone.now)
end
def collection_start_date(date)
Time.zone.local(collection_start_year(date), 4, 1)
end
def current_collection_start_date
Time.zone.local(current_collection_start_year, 4, 1)
end
def collection_end_date(date)
Time.zone.local(collection_start_year(date) + 1, 3, 31)
end
def current_collection_end_date
Time.zone.local(current_collection_start_year + 1, 3, 31)
end
end