Example #1
0
    def add_event(self, vevent):
        e = Event(
            vevent,
            self.first_day,
            self.last_day + datetime.timedelta(days=1),
            self.tz)

        for date, day in self.days.iteritems():
            if not e.is_all_day:

                for o in e.occurences(date):

                    row = {}
                    row['event'] = e
                    row['start'] = o
                    row['end'] = o + e.duration

                    offset_minutes = o.hour * 60 + o.minute
                    row['offset'] = ruler_units(offset_minutes)

                    duration_minutes = e.duration.total_seconds() / 60
                    row['duration'] = ruler_units(
                        adjust_duration(duration_minutes))

                    # TODO: if duration + offset > 86400 => clip and
                    # add extra event to next day

                    day.append(row)
Example #2
0
    def __init__(self):
        self.ruler = []

        ruler_minutes = 24 * 60
        self.ruler_duration = ruler_units(ruler_minutes)

        for hour in range(24):
            bar = {}

            offset_minutes = hour * 60
            bar['offset'] = ruler_units(offset_minutes)

            duration_minutes = 60
            bar['duration'] = ruler_units(adjust_duration(duration_minutes))

            bar['label'] = '{0}:00'.format(hour)

            self.ruler.append(bar)