def event_state(self): if self.end_dt: end = convert_date(self.end_dt, 'America/New_York') if end < datetime.now(timezone('America/New_York')): return 'past' if self.live_stream_date: start = convert_date(self.live_stream_date, 'America/New_York') else: start = convert_date(self.start_dt, 'America/New_York') if datetime.now(timezone('America/New_York')) > start: return 'present' return 'future'
def get_date_string(date, format="%Y-%m-%d", tz='America/New_York'): dt = convert_date(date, tz) return dt.strftime(format)