Python calendar.day_abbr() Examples

The following are 30 code examples of calendar.day_abbr(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module calendar , or try the search function .
Example #1
Source File: weekday_setbuilder.py    From aws-ops-automator with Apache License 2.0 6 votes vote down vote up
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 
Example #2
Source File: weekday_setbuilder.py    From aws-instance-scheduler with Apache License 2.0 6 votes vote down vote up
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 
Example #3
Source File: cal.py    From pyx with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #4
Source File: events.py    From uqcsbot with MIT License 6 votes vote down vote up
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 ''}" 
Example #5
Source File: Demo_LED_Clock_Weather.py    From PySimpleGUI with GNU Lesser General Public License v3.0 6 votes vote down vote up
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:]) 
Example #6
Source File: Demo_LED_Clock_Weather.py    From PySimpleGUI with GNU Lesser General Public License v3.0 6 votes vote down vote up
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:]) 
Example #7
Source File: cron.py    From synapse with Apache License 2.0 5 votes vote down vote up
def _parse_weekday(val):
        ''' Try to match a day-of-week abbreviation, then try a day-of-week full name '''
        val = val.title()
        try:
            return list(calendar.day_abbr).index(val)
        except ValueError:
            try:
                return list(calendar.day_name).index(val)
            except ValueError:
                return None 
Example #8
Source File: _strptime.py    From unity-python with MIT License 5 votes vote down vote up
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 
Example #9
Source File: _strptime.py    From android_universal with MIT License 5 votes vote down vote up
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 
Example #10
Source File: __init__.py    From pyirobot with MIT License 5 votes vote down vote up
def GetTime(self):
        """
        Get the time this robot is set to

        Returns:
            A dictionary with the time of day and day of week (dict)
        """
        result = self._PostToRobot("get", "time")
        day_idx = [idx for idx, day in enumerate(calendar.day_abbr) if day.lower() == result["d"]][0]
        return {
            "time" : datetime.time(result["h"], result["m"]),
            "weekday" : calendar.day_name[day_idx]
        } 
Example #11
Source File: _strptime.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #12
Source File: _strptime.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #13
Source File: _strptime.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #14
Source File: test_calendar.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #15
Source File: test_calendar.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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))) 
Example #16
Source File: calendar.py    From libreborme with GNU Affero General Public License v3.0 5 votes vote down vote up
def formatweekday(self, day):
        """
        Return a weekday name as a table header.
        """
        return '<th class="%s">%s</th>' % (self.cssclasses[day], day_abbr[day]) 
Example #17
Source File: test_calendar.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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))) 
Example #18
Source File: _strptime.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #19
Source File: test_calendar.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #20
Source File: _strptime.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #21
Source File: _strptime.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #22
Source File: _strptime.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #23
Source File: calendar.py    From choochoo with GNU General Public License v2.0 5 votes vote down vote up
def _add_labels(plot, start, finish, xlo, xhi, yhi, border_day, delta_year):
        for y in range(start.year, finish.year+1):
            plot.add_layout(Label(x=xhi + 1.1, y=(start.year - y - 0.4) * delta_year, text=str(y),
                                        text_align='center', text_baseline='bottom', angle=3*pi/2))
            for d, text in enumerate(day_abbr):
                plot.add_layout(Label(x=xlo - 1.5, y=(start.year - y) * delta_year - d * (1 + border_day),
                                      text=text, text_align='right', text_baseline='middle',
                                      text_font_size='7pt', text_color='grey'))
        dx = (xhi - xlo) / 12
        for m, text in enumerate(month_abbr[1:]):
            plot.add_layout(Label(x=xlo + dx * (m + 0.5), y=yhi + 1.5,
                                  text=text, text_align='center', text_baseline='bottom'))
        plot.toolbar.logo = None 
Example #24
Source File: date.py    From anki-search-inside-add-card with GNU Affero General Public License v3.0 5 votes vote down vote up
def weekday_name_abbr(wd: int) -> str:
    return list(calendar.day_abbr)[wd - 1] 
Example #25
Source File: test_calendar.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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))) 
Example #26
Source File: test_calendar.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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) 
Example #27
Source File: _strptime.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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 
Example #28
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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))) 
Example #29
Source File: test_calendar.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #30
Source File: _strptime.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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