def blackoutJson(self, blackout, calstart, calend, id = None, tz = None): # TBF: we are passing in id, but NOT using it! calstart = datetime.fromtimestamp(float(calstart)) calend = datetime.fromtimestamp(float(calend)) dates = blackout.generateDates(calstart, calend) if tz is not None: dates = [(adjustDateTimeTz(tz, s), adjustDateTimeTz(tz, e)) for s, e in dates] title = "%s: %s" % (blackout.forName() , blackout.getDescription() or "blackout") return [self.mkJson(blackout.id , title , d[0] if d[0] else None , d[1] if d[1] else None , 'blackout' ) for d in dates]
def periodJson(self, period, id, tz = None): end = period.start + timedelta(hours = period.duration) # TBF: use period.end(), and how come we ignore tz? #end = period.end() title = "".join(["Observing ", period.session.name]) start = adjustDateTimeTz(tz, period.start) if tz is not None \ else period.start return self.mkJson(id, title, start, end, 'period')