Skip to content

Commit d9ad8b8

Browse files
committed
Removed some dead code, simplified TimeSlot *_start_time() and *_end_time() methods, and added TimeSlot.local_date().
- Legacy-Id: 18784
1 parent a708bdf commit d9ad8b8

1 file changed

Lines changed: 12 additions & 22 deletions

File tree

ietf/meeting/models.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def build_timeslices(self):
245245
for ts in self.timeslot_set.all():
246246
if ts.location_id is None:
247247
continue
248-
ymd = ts.time.date()
248+
ymd = ts.local_date()
249249
if ymd not in time_slices:
250250
time_slices[ymd] = []
251251
slots[ymd] = []
@@ -474,9 +474,6 @@ def time_desc(self):
474474
t = self.local_start_time()
475475
return "%s-%s" % (t.strftime("%H%M"), (t + self.duration).strftime("%H%M"))
476476

477-
def meeting_date(self):
478-
return self.time.date()
479-
480477
def registration(self):
481478
# below implements a object local cache
482479
# it tries to find a timeslot of type registration which starts at the same time as this slot
@@ -541,28 +538,21 @@ def tz(self):
541538
return self._cached_tz
542539

543540
def tzname(self):
544-
if self.tz():
545-
return self.tz().tzname(self.time.replace(tzinfo=None))
541+
tz = self.tz()
542+
return tz.tzname(self.time.replace(tzinfo=None)) if tz else None
546543
def utc_start_time(self):
547-
if self.tz():
548-
return self.time.astimezone(pytz.utc)
549-
else:
550-
return None
544+
return self.time.astimezone(pytz.utc)
551545
def utc_end_time(self):
552-
if self.tz():
553-
return self.end_time().astimezone(pytz.utc)
554-
else:
555-
return None
546+
return self.end_time().astimezone(pytz.utc)
556547
def local_start_time(self):
557-
if self.tz():
558-
return self.time.astimezone(self.tz())
559-
else:
560-
return None
548+
tz = self.tz()
549+
return self.time.astimezone(tz) if tz else None
561550
def local_end_time(self):
562-
if self.tz():
563-
return self.end_time().astimezone(self.tz())
564-
else:
565-
return None
551+
tz = self.tz()
552+
return self.end_time().astimezone(tz) if tz else None
553+
def local_date(self):
554+
tz = self.tz()
555+
return self.time.astimezone(tz).date() if tz else None
566556

567557
@property
568558
def js_identifier(self):

0 commit comments

Comments
 (0)