Esempio n. 1
0
def get_dates(year):
    dates = []
    for term in oxford_term_dates.TERM_NAMES:
        try:
            term_start = oxford_term_dates.TERM_STARTS[(year, term)]
        except KeyError:
            continue
        for week in range(1, 9):
            for day in range(0, 7):
                date = term_start + timedelta(7*week+day)
                ox_date_dict = oxford_term_dates.ox_date_dict(date)
                dates.append({
                    'date': date.strftime('%Y-%m-%d'),
                    'title': '{day_name} of {week}{ordinal} week, {term_long} {year}'.format(**ox_date_dict),
                    #'oxfordDate': ox_date_dict,
                })
    return dates
Esempio n. 2
0
 def get_ox_components(self, datetime):
     """Returns date components for an arbitrary date
     :param datetime: datetime object
     :return: components for this date
     """
     return oxford_term_dates.ox_date_dict(datetime)
Esempio n. 3
0
 def get_today_components(self):
     """Returns today's date components (week number, term short/long)
     """
     return oxford_term_dates.ox_date_dict()
Esempio n. 4
0
 def test_first_day_term(self):
     defined = datetime(2012, 01, 8)
     dico = oxford_term_dates.ox_date_dict(defined)
     self.assertEqual(dico.get('term_short'), 'H')
     self.assertEqual(dico.get('term_long'), 'Hilary')
     self.assertEqual(dico.get('term'), 1)
Esempio n. 5
0
 def test_first_day_term(self):
     defined = datetime(2012, 1, 8)
     dico = oxford_term_dates.ox_date_dict(defined)
     self.assertEqual(dico.get('term_short'), 'H')
     self.assertEqual(dico.get('term_long'), 'Hilary')
     self.assertEqual(dico.get('term'), 1)
Esempio n. 6
0
 def test_format_nocal(self):
     dico = oxford_term_dates.ox_date_dict(datetime(2013, 5, 14))
     formatted = oxford_term_dates.format_date_nocal(dico)
     self.assertEqual("Tuesday, 4th week, Trinity 2013", formatted)
Esempio n. 7
0
 def test_format_nocal(self):
     dico = oxford_term_dates.ox_date_dict(datetime(2013, 5, 14))
     formatted = oxford_term_dates.format_date_nocal(dico)
     self.assertEqual("Tuesday, 4th week, Trinity 2013", formatted)