d = self.queryOffset(userId) d.addCallback(self.getSpans, scheds, x) return d def getSpans(self, rows, scheds, x): mktimestamp = lambda x: DateTime(2005, 5, 1 + x / 48, (x % 48) / 2, (x % 2) * 30) - DateTimeDelta(0,rows[0][0]) for sched in scheds: spans.append((mktimestamp(sched[0]), mktimestamp(sched[1]))) return spans