diff --git a/icekit_events/models.py b/icekit_events/models.py index a96ad21..17ac417 100644 --- a/icekit_events/models.py +++ b/icekit_events/models.py @@ -46,8 +46,6 @@ def zero_datetime(dt, tz=None): Return the given datetime with hour/minutes/seconds/ms zeroed and the timezone coerced to the given ``tz`` (or UTC if none is given). """ - if dt is None: - return None if tz is None: tz = get_current_timezone() return coerce_naive(dt).replace(hour=0, minute=0, second=0, microsecond=0) @@ -70,10 +68,6 @@ def default_date_starts(): return djtz.date() -def default_date_ends(): - return default_date_starts() + appsettings.DEFAULT_DATE_ENDS_DELTA - - def format_naive_ical_dt(date_or_datetime): """ Return datetime formatted for use in iCal as a *naive* datetime value to @@ -755,7 +749,7 @@ class Meta: def time_range_string(self): if self.is_all_day: - if self.duration <= timedelta(days=1): + if self.duration < timedelta(days=1): return u"""{0}, all day""".format( datefilter(self.local_start, DATE_FORMAT)) else: diff --git a/icekit_events/tests/tests.py b/icekit_events/tests/tests.py index 9365d14..a17bf2d 100644 --- a/icekit_events/tests/tests.py +++ b/icekit_events/tests/tests.py @@ -987,6 +987,38 @@ def setUp(self): rounding=timeutils.ROUND_DOWN) self.end = self.start + appsettings.DEFAULT_ENDS_DELTA + def test_time_range_string(self): + event = G(SimpleEvent) + + timed_occurrence = models.Occurrence.objects.create( + event=event, + start=djtz.datetime(2016,10,1, 9,0), + end=djtz.datetime(2016,10,1, 19,0), + ) + self.assertEquals( + 'Oct. 1, 2016 9 a.m. - Oct. 1, 2016 7 p.m.', + timed_occurrence.time_range_string()) + + single_day_all_day_occurrence = models.Occurrence.objects.create( + event=event, + start=djtz.datetime(2016,10,1, 0,0), + end=djtz.datetime(2016,10,1, 0,0), + is_all_day=True, + ) + self.assertEquals( + 'Oct. 1, 2016, all day', + single_day_all_day_occurrence.time_range_string()) + + multi_day_all_day_occurrence = models.Occurrence.objects.create( + event=event, + start=djtz.datetime(2016,10,1, 0,0), + end=djtz.datetime(2016,10,2, 0,0), + is_all_day=True, + ) + self.assertEquals( + 'Oct. 1, 2016 - Oct. 2, 2016, all day', + multi_day_all_day_occurrence.time_range_string()) + def test_initial_event_occurrences_automatically_created(self): event = G(SimpleEvent) self.assertEqual(event.occurrences.count(), 0)