Module: UKAcademicCalendar::DateAndTimeInstanceMethods
- Defined in:
- lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb
Overview
Mixin included in Date and Time classes providing academic year related instance methods
Instance Method Summary collapse
-
#academic_term ⇒ UKAcademicCalendar::AutumnTerm, ...
Term object including self.
-
#academic_year ⇒ Integer
Integer representing the calendar year within the academic year started in.
-
#academic_year_month ⇒ Integer
Integer representing the month of the academic year including self.
-
#beginning_of_academic_term ⇒ #to_date
Instance of self.class representing the beginning of the academic term including self.
-
#beginning_of_academic_year ⇒ #to_date
Instance of self.class representing the beginning of the academic year.
-
#end_of_academic_term ⇒ #to_date
Instance of self.class representing the end of the academic term including self.
-
#end_of_academic_year ⇒ #to_date
Instance of self.class representing the end of the academic year.
Instance Method Details
#academic_term ⇒ UKAcademicCalendar::AutumnTerm, ...
Returns term object including self.
52 53 54 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 52 def academic_term UKAcademicCalendar.term_including self end |
#academic_year ⇒ Integer
Returns integer representing the calendar year within the academic year started in.
10 11 12 13 14 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 10 def academic_year return year if yday >= start_yday year - 1 end |
#academic_year_month ⇒ Integer
Returns integer representing the month of the academic year including self.
42 43 44 45 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 42 def academic_year_month ac_yr_start_month = YEAR_OFFSET_START_MONTH ((month - ac_yr_start_month) % 12) + 1 end |
#beginning_of_academic_term ⇒ #to_date
Returns instance of self.class representing the beginning of the academic term including self.
60 61 62 63 64 65 66 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 60 def beginning_of_academic_term term_start = academic_term.start_date shifted = change(year: term_start.year, month: term_start.month, day: term_start.day) return shifted unless acts_like? :time shifted.beginning_of_day end |
#beginning_of_academic_year ⇒ #to_date
Returns instance of self.class representing the beginning of the academic year.
20 21 22 23 24 25 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 20 def beginning_of_academic_year shifted = change(year: academic_year, month: YEAR_OFFSET_START_MONTH, day: 1) return shifted unless acts_like? :time shifted.beginning_of_day end |
#end_of_academic_term ⇒ #to_date
Returns instance of self.class representing the end of the academic term including self.
72 73 74 75 76 77 78 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 72 def end_of_academic_term term_end = academic_term.end_date shifted = change(year: term_end.year, month: term_end.month, day: term_end.day) return shifted unless acts_like? :time shifted.end_of_day end |
#end_of_academic_year ⇒ #to_date
Returns instance of self.class representing the end of the academic year.
31 32 33 34 35 36 |
# File 'lib/uk_academic_calendar/mixins/date_and_time_instance_methods.rb', line 31 def end_of_academic_year shifted = beginning_of_academic_year.next_year.prev_day return shifted unless acts_like? :time shifted.end_of_day end |