示例#1
0
def calcEntries():
    today = datetime.today()
    
    count = 5
    dates = []
    maxDate = []
    
    if K4CG_ACTIVE:
        k4cg = list(rrule(MONTHLY, count=count, byweekday=TH(1), dtstart=today, wkst=MO))
        for dateEntry in k4cg:
            dates.append(k4cgEntry(dateEntry))
            maxDate.append(dateEntry)

    if FABLAB_ACTIVE:
        fablab = list(rrule(MONTHLY, count=count, byweekday=TU(3), dtstart=today, wkst=MO))
        for dateEntry in fablab:
            dates.append(fablabEntry(dateEntry))
            maxDate.append(dateEntry)

    if NERDBERG_ACTIVE:
        if len(maxDate) == 0:
            maxDate.append(today + timedelta(weeks=12))
        ical_string = urllib.request.urlopen("https://kalender.nerdberg.de/events.ics").read()
        calendar = icalendar.Calendar.from_ical(ical_string)
        events = recurring_ical_events.of(calendar).between(today, max(maxDate))
        for event in events:
            if event['Summary'] == "Chaostreff":
                dates.append(nerdbergEntry(event['dtstart'].dt.replace(tzinfo=None)))

    dates.sort(key=lambda entry: entry.date)
    return dates
示例#2
0
 def test_monthly_month_nweekday(self):
     rule = rrule(MONTHLY,
                  bymonth=(1, 3),
                  byweekday=(TU(1), TH(-1)),
                  dtstart=datetime.datetime(1997, 9, 2, 9, 0))
     vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
     vRecur(vrecurr).to_ical().decode(
     ) == 'FREQ=MONTHLY;BYDAY=+1TU,-1TH;BYMONTH=1,3'
示例#3
0
 def test_daily_by_month_nweekday(self):
     rule = rrule(DAILY,
                  count=3,
                  bymonth=(1, 3),
                  byweekday=(TU(1), TH(-1)),
                  dtstart=datetime.datetime(1997, 9, 2, 9, 0))
     vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
     vRecur(vrecurr).to_ical().decode(
     ) == 'FREQ=DAILY;COUNT=3;BYDAY=TU,TH;BYMONTH=1,3'
 def test_monthly_nweekday(self):
     rule = rrule(
         MONTHLY,
         count=3,
         byweekday=(TU(1), TH(-1)),
         dtstart=datetime.datetime(1997, 9, 2, 9, 0),
     )
     vrecurr = utils.build_rrule_from_dateutil_rrule(rule)
     vRecur(vrecurr).to_ical().decode(
     ) == "FREQ=MONTHLY;COUNT=3;BYDAY=+1TU,-1TH"
示例#5
0
 def __init__(self, now):
     super(Thanksgiving,
           self).__init__(peak=rrule(YEARLY, byweekday=TH(
               4), bymonth=11).after(datetime(now.year, 1, 1)))
示例#6
0
def schedule_quality_meetings():
    next_thursday = date.today() + relativedelta(weekday=TH(+1))
    print(next_thursday)
    meetings = list(rrule(WEEKLY, count=10, dtstart=next_thursday))
    pp(meetings)
示例#7
0
    zh_hans="国庆节",
    zh_hant="國慶節",
)

Halloween = Festival(
    lambda year: datetime.date(year, 10, 31),
    en="Halloween",
    zh_hans="万圣夜,万圣节前夜,万鬼节",
    zh_hant="萬聖夜,萬聖節前夜,萬鬼節",
)

Thanksgiving = Festival(
    lambda year: rrule(MONTHLY,
                       count=1,
                       bymonth=11,
                       byweekday=TH(4),
                       dtstart=datetime.datetime(year, 11, 1))[0].date(),
    en="Thanksgiving Day",
    zh_hans="感恩节",
    zh_hant="感恩節",
)

ChristmasEve = Festival(
    lambda year: datetime.date(year, 12, 24),
    en="Christmas Eve",
    zh_hans="平安夜,圣诞夜,圣诞节前夕",
    zh_hant="平安夜,聖誕夜,聖誕節前夕",
)

ChristmasDay = Festival(
    lambda year: datetime.date(year, 12, 25),
示例#8
0
        return template % (dateString, self.location, self.time)


def k4cgEntry(date: datetime):
    return Entry(date, 'K4CG', '19:30 - 22:00')


def fablabEntry(date: datetime):
    return Entry(date, 'Fablab Region Nürnberg', '19:30 - 22:00')


today = date.today()

count = 5
dates = []

k4cg = list(
    rrule(MONTHLY, count=count, byweekday=TH(1), dtstart=today, wkst=MO))
for dateEntry in k4cg:
    dates.append(k4cgEntry(dateEntry))

fablab = list(
    rrule(MONTHLY, count=count, byweekday=TU(3), dtstart=today, wkst=MO))
for dateEntry in fablab:
    dates.append(fablabEntry(dateEntry))

dates.sort(key=lambda entry: entry.date)

for dateEntry in dates:
    print(dateEntry.asHTML())