def get_day_events(self, match_num) -> tuple: if match_num == 2 or match_num == 12 or match_num == 22 or match_num == 32: daystr = "今天" date = Arrow.now(tzinfo=self.timezone) elif match_num == 3 or match_num == 13 or match_num == 23 or match_num == 33: daystr = "明天" date = Arrow.now(tzinfo=self.timezone) + datetime.timedelta(days=1) elif match_num & 0xf00000 == 0x100000: year = (match_num & 0xff000) >> 12 month = (match_num & 0xf00) >> 8 day = match_num & 0xff daystr = "{}年{}月{}日".format(2000 + year, month, day) try: date = Arrow(2000 + year, month, day) except ValueError as v: raise InputError("日期错误:{}".format(v)) if match_num - 30 > 0: daystr = "日服" + daystr events = self.timeline_jp.at(date) elif match_num - 20 > 0: daystr = "台服" + daystr events = self.timeline_tw.at(date) elif match_num - 10 > 0: daystr = "国服" + daystr events = self.timeline_cn.at(date) else: daystr = self.region[self.setting.get("calender_region", "default")] + daystr events = self.timeline.at(date) return (daystr, events)
def get_day_events(self, match_num, region) -> tuple: if match_num == 2: daystr = "今天" date = Arrow.now(tzinfo=self.timezone) elif match_num == 3: daystr = "明天" date = Arrow.now(tzinfo=self.timezone) + datetime.timedelta(days=1) elif match_num & 0xf00000 == 0x100000: year = (match_num & 0xff000) >> 12 month = (match_num & 0xf00) >> 8 day = match_num & 0xff daystr = "{}年{}月{}日".format(2000 + year, month, day) try: date = Arrow(2000 + year, month, day) except ValueError as v: raise InputError("日期错误:{}".format(v)) timeline = self.timeline_cn if region == "jp": timeline = self.timeline_jp elif region == "tw": timeline = self.timeline_tw if not timeline: events = None else: events = timeline.at(date) return (daystr, events)
def get_day_events(self, match_num) -> tuple: if match_num == 2: daystr = "今天" date = Arrow.now(tzinfo=self.timezone) elif match_num == 3: daystr = "明天" date = Arrow.now(tzinfo=self.timezone) + datetime.timedelta(days=1) elif match_num & 0xf00000 == 0x100000: year = (match_num & 0xff000) >> 12 month = (match_num & 0xf00) >> 8 day = match_num & 0xff daystr = "{}年{}月{}日".format(2000 + year, month, day) try: date = Arrow(2000 + year, month, day) except ValueError as v: logger.error(f'日期错误{v}') events = self.timeline.at(date) return (daystr, events)
def get_day_events(self, date_num, rg) -> tuple: if date_num == 2: daystr = "今天" date = Arrow.now(tzinfo=self.timezone) elif date_num == 3: daystr = "明天" date = Arrow.now(tzinfo=self.timezone) + datetime.timedelta(days=1) elif date_num & 0xf00000 == 0x100000: year = (date_num & 0xff000) >> 12 month = (date_num & 0xf00) >> 8 day = date_num & 0xff daystr = "{}年{}月{}日".format(2000 + year, month, day) try: date = Arrow(2000 + year, month, day) except ValueError as v: raise InputError("日期错误:{}".format(v)) else: raise ValueError(f'unespected date_num: {date_num}') events = self.timelines[rg].at(date) return (daystr, events)
'B': 'Bach', 'C': 'Conrad', 'D': 'Donovan', 'E': 'Emery', 'F': 'Frisk', 'G': 'Gonzalez' } student: Student = Student('hpeng2021', 'Michael Peng', schedules={2: student_schedule}) case = IcsCalendarCase() ahs_timezone = 'America/New_York' expected_events = { Event(name='A Block with Aubrey', begin=Arrow(2020, 4, 6, 8, 30, tzinfo=ahs_timezone), end=Arrow(2020, 4, 6, 9, 15, tzinfo=ahs_timezone), categories=['AHS at home', 'AHS at home: A Block'], alarms=[AudioAlarm(-datetime.timedelta(minutes=5))]), Event(name='C Block with Conrad', begin=Arrow(2020, 4, 6, 9, 30, tzinfo=ahs_timezone), end=Arrow(2020, 4, 6, 10, 15, tzinfo=ahs_timezone), categories=['AHS at home', 'AHS at home: C Block'], alarms=[AudioAlarm(-datetime.timedelta(minutes=5))]), Event(name='E Block with Emery', begin=Arrow(2020, 4, 6, 10, 30, tzinfo=ahs_timezone), end=Arrow(2020, 4, 6, 11, 15, tzinfo=ahs_timezone), categories=['AHS at home', 'AHS at home: E Block'], alarms=[AudioAlarm(-datetime.timedelta(minutes=5))]), Event(name='G Block with Gonzalez', begin=Arrow(2020, 4, 6, 11, 30, tzinfo=ahs_timezone),
def arw(): return Arrow(*test_config['initial_date'])