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.
sqm-dashboards/app/models/academic_year.rb

19 lines
436 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class AcademicYear < ActiveRecord::Base
def self.find_by_date(date)
if date.month > 6
ay_range_start = date.year
ay_range_end = date.year + 1
else
ay_range_start = date.year - 1
ay_range_end = date.year
end
AcademicYear.find_by_range("#{ay_range_start}-#{ay_range_end.to_s[2, 3]}")
end
def formatted_range
years = range.split('-')
"#{years.first} 20#{years.second}"
end
end