当前位置: 首页>>代码示例>>Python>>正文


Python calendar.day_abbr方法代码示例

本文整理汇总了Python中calendar.day_abbr方法的典型用法代码示例。如果您正苦于以下问题:Python calendar.day_abbr方法的具体用法?Python calendar.day_abbr怎么用?Python calendar.day_abbr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在calendar的用法示例。


在下文中一共展示了calendar.day_abbr方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def __init__(self, wrap=True, year=None, month=None, day=None, ignore_case=True):
        """

        :param wrap: Set to True to allow wrapping at last day of the week
        :param year: Year of week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param month: Month of week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param day:  Day in week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param ignore_case: Set to True to ignore case when mapping day names to set values
        """
        SetBuilder.__init__(self,
                            names=calendar.day_abbr,
                            wrap=wrap,
                            ignore_case=ignore_case,
                            significant_name_characters=3,
                            last_item_wildcard=WeekdaySetBuilder.LAST_DAY_WILDCARD)
        self._year = year
        self._month = month
        self._day = day
        self._first_weekday_in_month = None
        self._days_in_month = None

        self._post_custom_parsers = [self._parse_name_number,  # name#num
                                     self._parse_value_number,  # value#num
                                     self._parse_name_last_weekday,  # nameL
                                     self._parse_value_last_weekday]  # valueL 
开发者ID:awslabs,项目名称:aws-ops-automator,代码行数:27,代码来源:weekday_setbuilder.py

示例2: drawpoint

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def drawpoint(self, privatedata, sharedata, graph, point):
        # draw a single day
        x1_pt, y1_pt = graph.pos_pt((point["month"], 0), (point["day"], 0))
        x2_pt, y2_pt = graph.pos_pt((point["month"], 1), (point["day"], 1))
        p = path.rect_pt(x1_pt, y1_pt, x2_pt - x1_pt, y2_pt - y1_pt)
        if point["weekday"] == calendar.day_abbr[-1]:
            graph.stroke(p, [deco.filled([color.gray(0.8)])])
        else:
            graph.stroke(p)
        graph.text_pt(x1_pt+3, y2_pt-3,
                      "%i %s" % (point["day"], point["weekday"]),
                      [text.valign.top])
        if point["note"]:
            graph.text_pt(x1_pt+3, y1_pt+3, point["note"], [text.size.tiny])

# create calendar data 
开发者ID:pyx-project,项目名称:pyx,代码行数:18,代码来源:cal.py

示例3: __str__

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def __str__(self):
        d1 = self.start.astimezone(BRISBANE_TZ)
        d2 = self.end.astimezone(BRISBANE_TZ)

        start_str = (f"{day_abbr[d1.weekday()].upper()}"
                     + f" {month_abbr[d1.month].upper()} {d1.day} {d1.hour}:{d1.minute:02}")
        if (d1.month, d1.day) != (d2.month, d2.day):
            end_str = (f"{day_abbr[d2.weekday()].upper()}"
                       + f" {month_abbr[d2.month].upper()} {d2.day} {d2.hour}:{d2.minute:02}")
        else:
            end_str = f"{d2.hour}:{d2.minute:02}"

        # Encode user-provided text to prevent certain characters
        # being interpreted as slack commands.
        summary_str = Event.encode_text(self.summary)
        location_str = Event.encode_text(self.location)

        if self.link is None:
            return f"{'*' if self.source == 'UQCS' else ''}" \
                   f"`{summary_str}`" \
                   f"{'*' if self.source == 'UQCS' else ''}\n" \
                   f"*{start_str} - {end_str}* {'_(' + location_str + ')_' if location_str else ''}"
        else:
            return f"`<{self.link}|{summary_str}>`\n" \
                   f"*{start_str} - {end_str}* {'_(' + location_str + ')_' if location_str else ''}" 
开发者ID:UQComputingSociety,项目名称:uqcsbot,代码行数:27,代码来源:events.py

示例4: update_weather

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def update_weather(self):
        forecast = forecastio.load_forecast(self.api_key, self.lat, self.lng)
        daily = forecast.daily()
        today_weekday = datetime.datetime.today().weekday()

        max_temps = []
        min_temps = []
        daily_icons = []
        for daily_data in daily.data:
            daily_icons.append(daily_data.d['icon'])
            max_temps.append(int(daily_data.d['temperatureMax']))
            min_temps.append(int(daily_data.d['temperatureMin']))

        for i in range(NUM_COLS):
            day_element = self.window.FindElement('_DAY_' + str(i))
            max_element = self.window.FindElement('_high_' + str(i))
            min_element = self.window.FindElement('_low_' + str(i))
            icon_element = self.window.FindElement('_icon_' + str(i))
            day_element.Update(calendar.day_abbr[(today_weekday + i) % 7])
            max_element.Update(max_temps[i])
            min_element.Update(min_temps[i])
            icon_element.Update(data=weather_icon_dict[daily_icons[i]][22:]) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:24,代码来源:Demo_LED_Clock_Weather.py

示例5: update_weather

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def update_weather(self):
        forecast = forecastio.load_forecast(self.api_key, self.lat, self.lng)
        daily = forecast.daily()
        today_weekday = datetime.datetime.today().weekday()

        max_temps = []
        min_temps = []
        daily_icons = []
        for daily_data in daily.data:
            daily_icons.append(daily_data.d['icon'])
            max_temps.append(int(daily_data.d['temperatureMax']))
            min_temps.append(int(daily_data.d['temperatureMin']))

        for i in range(NUM_COLS):
            day_element = self.window['-DAY-' + str(i)]
            max_element = self.window['-high-' + str(i)]
            min_element = self.window['-low-' + str(i)]
            icon_element = self.window['-icon-' + str(i)]
            day_element.update(calendar.day_abbr[(today_weekday + i) % 7])
            max_element.update(max_temps[i])
            min_element.update(min_temps[i])
            icon_element.update(data=weather_icon_dict[daily_icons[i]][22:]) 
开发者ID:PySimpleGUI,项目名称:PySimpleGUI,代码行数:24,代码来源:Demo_LED_Clock_Weather.py

示例6: __init__

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def __init__(self, wrap=True, year=None, month=None, day=None, ignorecase=True):
        """

        :param wrap: Set to True to allow wrapping at last day of the week
        :param year: Year of week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param month: Month of week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param day:  Day in week to build sets for, only required for date aware '#' and 'L' features in expressions
        :param ignorecase: Set to True to ignore case when mapping day names to set values
        """
        SetBuilder.__init__(self,
                            names=calendar.day_abbr,
                            wrap=wrap,
                            ignorecase=ignorecase,
                            significant_name_characters=3,
                            last_item_wildcard=WeekdaySetBuilder.LAST_DAY_WILDCARD)
        self._year = year
        self._month = month
        self._day = day
        self._first_weekday_in_month = None
        self._days_in_month = None

        self._post_custom_parsers = [self._parse_name_number,  # name#num
                                     self._parse_value_number,  # value#num
                                     self._parse_name_last_weekday,  # nameL
                                     self._parse_value_last_weekday]  # valueL 
开发者ID:awslabs,项目名称:aws-instance-scheduler,代码行数:27,代码来源:weekday_setbuilder.py

示例7: test_name

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_name(self):
        for i, day_name in enumerate(calendar.day_abbr):
            self.assertEqual(WeekdaySetBuilder().build(day_name), {i})

        for i, day_name in enumerate(calendar.day_name):
            self.assertEqual(WeekdaySetBuilder().build(day_name), {i}) 
开发者ID:awslabs,项目名称:aws-ops-automator,代码行数:8,代码来源:test_weekday_setbuilder.py

示例8: test_value

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_value(self):
        for i in range(0, len(calendar.day_abbr) - 1):
            self.assertEqual(WeekdaySetBuilder().build(str(i)), {i}) 
开发者ID:awslabs,项目名称:aws-ops-automator,代码行数:5,代码来源:test_weekday_setbuilder.py

示例9: test_L_wildcard

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_L_wildcard(self):

        for year in [2016, 2017]:
            for month in range(1, 13):
                weekday, days_in_month = calendar.monthrange(year, month)
                for tested_on_day in range(1, days_in_month + 1):
                    builder = WeekdaySetBuilder(year=year, month=month, day=tested_on_day)

                    # test by name of weekday
                    day_num_l = calendar.day_abbr[weekday] + "L"
                    tested_by_name = builder.build(day_num_l)
                    # test by number of weekday
                    day_value_l = str(weekday) + "L"
                    tested_by_value = builder.build(day_value_l)

                    # everything before last week should be empty set
                    if tested_on_day <= (days_in_month - 7):
                        self.assertEqual(tested_by_name, set())
                        self.assertEqual(tested_by_value, set())
                    else:
                        # in last week the set should contain the day
                        self.assertEqual(tested_by_name, {weekday})
                        self.assertEqual(tested_by_value, {weekday})

                        # test if other weekdays on that day return empty set
                        for d in range(0, 6):
                            if d != weekday:
                                day_num_l = calendar.day_abbr[d] + "L"
                                day_value_l = str(d) + "L"
                                self.assertEqual(builder.build(day_num_l), set())
                                self.assertEqual(builder.build(day_value_l), set())

                    weekday = (weekday + 1) % 7 
开发者ID:awslabs,项目名称:aws-ops-automator,代码行数:35,代码来源:test_weekday_setbuilder.py

示例10: test_weekday_numbered

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_weekday_numbered(self):

        for year in [2016, 2017]:
            for month in range(1, 13):
                weekday, days_in_month = calendar.monthrange(year, month)

                for day in range(1, days_in_month + 1):
                    num = int((day - 1) / 7) + 1
                    builder = WeekdaySetBuilder(year=year, month=month, day=day)

                    tested_by_name = builder.build(calendar.day_abbr[weekday] + "#" + str(num))
                    self.assertEqual(tested_by_name, {weekday})

                    tested_by_value = builder.build(str(weekday) + "#" + str(num))
                    self.assertEqual(tested_by_value, {weekday})

                    for other_weekday in range(0, 7):
                        if other_weekday != weekday:
                            tested_by_name = builder.build(calendar.day_abbr[other_weekday] + "#" + str(num))
                            self.assertEqual(tested_by_name, set())
                            tested_by_value = builder.build(str(other_weekday) + "#" + str(num))
                            self.assertEqual(tested_by_value, set())

                    for other_num in range(1, 6):
                        if num != other_num:
                            tested_by_name = builder.build(calendar.day_abbr[weekday] + "#" + str(other_num))
                            self.assertEqual(tested_by_name, set())
                            tested_by_value = builder.build(str(weekday) + "#" + str(other_num))
                            self.assertEqual(tested_by_value, set())

                    weekday = (weekday + 1) % 7 
开发者ID:awslabs,项目名称:aws-ops-automator,代码行数:33,代码来源:test_weekday_setbuilder.py

示例11: __calc_weekday

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def __calc_weekday(self):
        # Set self.a_weekday and self.f_weekday using the calendar
        # module.
        a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
        f_weekday = [calendar.day_name[i].lower() for i in range(7)]
        self.a_weekday = a_weekday
        self.f_weekday = f_weekday 
开发者ID:war-and-code,项目名称:jawfish,代码行数:9,代码来源:_strptime.py

示例12: test_enumerateweekdays

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_enumerateweekdays(self):
        self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10)
        self.assertRaises(IndexError, calendar.day_name.__getitem__, 10)
        self.assertEqual(len([d for d in calendar.day_abbr]), 7) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_calendar.py

示例13: test_days

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_days(self):
        for attr in "day_name", "day_abbr":
            value = getattr(calendar, attr)
            self.assertEqual(len(value), 7)
            self.assertEqual(len(value[:]), 7)
            # ensure they're all unique
            self.assertEqual(len(set(value)), 7)
            # verify it "acts like a sequence" in two forms of iteration
            self.assertEqual(value[::-1], list(reversed(value))) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_calendar.py

示例14: test_enumerate_weekdays

# 需要导入模块: import calendar [as 别名]
# 或者: from calendar import day_abbr [as 别名]
def test_enumerate_weekdays(self):
        self.assertRaises(IndexError, calendar.day_abbr.__getitem__, -10)
        self.assertRaises(IndexError, calendar.day_name.__getitem__, 10)
        self.assertEqual(len([d for d in calendar.day_abbr]), 7) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_calendar.py


注:本文中的calendar.day_abbr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。