sqm-dashboards/app/models/academic_year.rb

18 lines
436 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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