Python calendar.month_name() Examples

The following are 30 code examples of calendar.month_name(). 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: calendar_helpers.py    From woid with Apache License 2.0 8 votes vote down vote up
def month_name(month):
    names = {
        '01': 'January',
        '02': 'February',
        '03': 'March',
        '04': 'April',
        '05': 'May',
        '06': 'June',
        '07': 'July',
        '08': 'August',
        '09': 'September',
        '10': 'October',
        '11': 'November',
        '12': 'December',
    }
    return names[month] 
Example #2
Source File: joyous_tags.py    From ls.joyous with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def minicalendar(context):
    """
    Displays a little ajax version of the calendar.
    """
    today = timezone.localdate()
    request = context['request']
    home = request.site.root_page
    cal = CalendarPage.objects.live().descendant_of(home).first()
    calUrl = cal.get_url(request) if cal else None
    if cal:
        events = cal._getEventsByWeek(request, today.year, today.month)
    else:
        events = getAllEventsByWeek(request, today.year, today.month)
    return {'request':     request,
            'today':       today,
            'year':        today.year,
            'month':       today.month,
            'calendarUrl': calUrl,
            'monthName':   calendar.month_name[today.month],
            'weekdayInfo': zip(weekday_abbr, weekday_name),
            'events':      events} 
Example #3
Source File: views.py    From opencraft with GNU Affero General Public License v3.0 6 votes vote down vote up
def report(request, organization, year, month):
    """
    Report view
    """
    try:
        invoice_start_date = timezone.make_aware(datetime(int(year), int(month), 1))
    except ValueError:
        return HttpResponseBadRequest(
            content='<h1>Bad Request</h1>'
                    '<p>Error when processing given date, consider using parameters within range</p>'
        )

    organization = get_object_or_404(Organization, github_handle=organization)
    forks_instances = generate_watched_forks_instances(organization)
    billing_data, total = generate_charges(forks_instances, invoice_start_date)

    return render(request, 'report.html', context={
        'year': year,
        'month': month,
        'month_name': calendar.month_name[int(month)],
        'organization': organization,
        'billing_data': billing_data,
        'total': total,
    }) 
Example #4
Source File: stormtypes.py    From synapse with Apache License 2.0 6 votes vote down vote up
def _parseReq(self, requnit, reqval):
        ''' Parse a non-day fixed value '''
        assert reqval[0] != '='

        try:
            retn = []
            for val in reqval.split(','):
                if requnit == 'month':
                    if reqval[0].isdigit():
                        retn.append(int(reqval))  # must be a month (1-12)
                    else:
                        try:
                            retn.append(list(calendar.month_abbr).index(val.title()))
                        except ValueError:
                            retn.append(list(calendar.month_name).index(val.title()))
                else:
                    retn.append(int(val))
        except ValueError:
            return None

        return retn[0] if len(retn) == 1 else retn 
Example #5
Source File: cron.py    From synapse with Apache License 2.0 6 votes vote down vote up
def _parse_req(requnit, reqval):
        ''' Parse a non-day fixed value '''
        assert reqval[0] != '='

        try:
            retn = []
            for val in reqval.split(','):
                if requnit == 'month':
                    if reqval[0].isdigit():
                        retn.append(int(reqval))  # must be a month (1-12)
                    else:
                        try:
                            retn.append(list(calendar.month_abbr).index(val.title()))
                        except ValueError:
                            retn.append(list(calendar.month_name).index(val.title()))
                else:
                    retn.append(int(val))
        except ValueError:
            return None

        if not retn:
            return None

        return retn[0] if len(retn) == 1 else retn 
Example #6
Source File: test_timestamp.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_names(self, data, time_locale):
        # GH 17354
        # Test .weekday_name, .day_name(), .month_name
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            assert data.weekday_name == 'Monday'
        if time_locale is None:
            expected_day = 'Monday'
            expected_month = 'August'
        else:
            with tm.set_locale(time_locale, locale.LC_TIME):
                expected_day = calendar.day_name[0].capitalize()
                expected_month = calendar.month_name[8].capitalize()

        assert data.day_name(time_locale) == expected_day
        assert data.month_name(time_locale) == expected_month

        # Test NaT
        nan_ts = Timestamp(NaT)
        assert np.isnan(nan_ts.day_name(time_locale))
        assert np.isnan(nan_ts.month_name(time_locale)) 
Example #7
Source File: calendars.py    From django-happenings with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def formatmonthname(self, theyear, themonth, withyear=True):
        """
        Change colspan to "5", add "today" button, and return a month
        name as a table row.
        """
        display_month = month_name[themonth]

        if isinstance(display_month, six.binary_type) and self.encoding:
            display_month = display_month.decode(self.encoding)

        if withyear:
            s = u'%s %s' % (display_month, theyear)
        else:
            s = u'%s' % display_month
        return ('<tr><th colspan="5" class="month">'
                '<button id="cal-today-btn" class="btn btn-small">'
                'Today</button> %s</th></tr>' % s) 
Example #8
Source File: FbTime.py    From booksoup with MIT License 6 votes vote down vote up
def span_meta_to_date(self, span_str, interval="month"):
        # Remove all occurences of commas except the first one
        if span_str.count(",") == 2:
            span_str = ''.join(span_str.rsplit(',', 1))

        date_arr = span_str.split(", ")[1].split(" ")[:3]

        # Re-arrange date_arr if format is month-day-year.
        try:
            a = int(date_arr[0])
        except ValueError:
            shuffled_date_arr = [date_arr[1], date_arr[0], date_arr[2]]
            date_arr = shuffled_date_arr

        date_str = date_arr[2]+"-"+self.__pad(list(calendar.month_name).index(date_arr[1]))
        if interval == "day":
            date_str += "-"+self.__pad(date_arr[0])
        return date_str 
Example #9
Source File: schedules.py    From cvpysdk with Apache License 2.0 6 votes vote down vote up
def yearly(self):
        """
        gets the yearly schedule
                Returns: (dict) -- The schedule pattern
                        {
                                 "active_start_time": time_in_%H/%S (str),
                                 "on_month": month to run schedule (str) January, Febuary...
                                 "on_day": Day to run schedule (int)
                        }
                False: if schedule type is wrong
        """
        if self.schedule_freq_type == 'Yearly':
            return {'active_start_time':
                    SchedulePattern._time_converter(self._pattern['active_start_time'],
                                                    '%H:%M', False),
                    'on_month': calendar.month_name[self._pattern['freq_recurrence_factor']],
                    'on_day': self._pattern['freq_interval']
                    }
        return False 
Example #10
Source File: schedules.py    From cvpysdk with Apache License 2.0 6 votes vote down vote up
def yearly_relative(self):
        """
        gets the yearly_relative schedule
                Returns: (dict) The schedule pattern
                    {
                             "active_start_time": time_in_%H/%S (str),
                             "relative_time": relative day of the schedule (str)'first','second',..
                             "relative_weekday": Day to run schedule (str) 'sunday','monday'...
                             "on_month": month to run the schedule(str) January, Febuary...
                    }
                False: if schedule type is wrong
        """
        if self.schedule_freq_type == 'Yearly_Relative':
            return {'active_start_time':
                    SchedulePattern._time_converter(self._pattern['active_start_time'],
                                                    '%H:%M', False),
                    'relative_time': SchedulePattern._relative_day
                    [self._pattern['freq_relative_interval']],
                    'relative_weekday': SchedulePattern._relative_weekday
                    [self._pattern['freq_interval']],
                    'on_month': calendar.month_name[self._pattern['freq_recurrence_factor']]
                    }
        return False 
Example #11
Source File: _strptime.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #12
Source File: _strptime.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #13
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Reset(self, list):
        tmpList = []
        for item in list:
            day = item[-1]
            day = "  %i" % day if day < 10 else "%i" % day
            if len(item) == 2:
                tmpList.append("%s. %s" % (day, month_name[item[0]]))
            else:
                tmpList.append("%s. %s %i" % (day, month_name[item[1]], item[0]))
        self.Set(tmpList)
        if self.sel > -1 and self.sel < self.GetCount():
            self.SetSelection(self.sel)
            return False
        else:
            return True 
Example #14
Source File: main.py    From python-examples with MIT License 5 votes vote down vote up
def formatmonthname(self, theyear, themonth, withyear=True):
        with calendar.different_locale(self.locale):
            s = calendar.month_name[themonth].capitalize()
            if withyear:
                s = '%s %s' % (s, theyear)
            return '<tr><th colspan="7" class="month">%s</th></tr>' % s 
Example #15
Source File: main.py    From python-examples with MIT License 5 votes vote down vote up
def formatmonthname(self, theyear, themonth, width, withyear=True):
        """
        Return a formatted month name.
        """
        s = calendar.month_name[themonth]
        #if withyear:
        s = "%s %r" % (s, theyear)
        return s.center(width) 
Example #16
Source File: _strptime.py    From unity-python with MIT License 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #17
Source File: _strptime.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #18
Source File: _strptime.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #19
Source File: _strptime.py    From android_universal with MIT License 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #20
Source File: _strptime.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #21
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_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #22
Source File: _strptime.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #23
Source File: calendars.py    From django-happenings with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def popover_helper(self):
        """Populate variables used to build popovers."""
        # when
        display_month = month_name[self.mo]

        if isinstance(display_month, six.binary_type) and self.encoding:
            display_month = display_month.decode('utf-8')

        self.when = ('<p><b>When:</b> ' + display_month + ' ' +
                     str(self.day) + ', ' + self.event.l_start_date.strftime(
                         LEGACY_CALENDAR_TIME_FORMAT).lstrip('0') + ' - ' +
                     self.event.l_end_date.strftime(LEGACY_CALENDAR_TIME_FORMAT).lstrip('0') +
                     '</p>')

        if self.event.location.exists():  # where
            self.where = '<p><b>Where:</b> '
            for l in self.event.location.all():
                self.where += l.name
            self.where += '</p>'
        else:
            self.where = ''

        # description
        self.desc = '<p><b>Description:</b> ' + self.event.description[:100]
        self.desc += ('...</p>' if len(self.event.description) > 100
                      else '</p>')

        self.event_url = self.event.get_absolute_url()  # url
        t = LEGACY_CALENDAR_TIME_FORMAT if self.event.l_start_date.minute else LEGACY_CALENDAR_HOUR_FORMAT
        self.title2 = (self.event.l_start_date.strftime(t).lstrip('0') +
                       ' ' + self.title) 
Example #24
Source File: calendars.py    From django-happenings with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def get_display_month(self, themonth):
        display_month = month_name[themonth]

        if isinstance(display_month, six.binary_type) and self.encoding:
            display_month = display_month.decode(self.encoding)
        return display_month 
Example #25
Source File: test_month_view.py    From django-happenings with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test_list_view_cal_ignore_querystrings(self):
        """cal_ignore qs should set time to now."""
        response = self.client.get(
            reverse('calendar:list'), {'cal_ignore': 'true'}
        )
        self.assertContains(response, month_name[timezone.now().month])
        self.assertContains(response, timezone.now().year) 
Example #26
Source File: tibia.py    From NabBot with Apache License 2.0 5 votes vote down vote up
def world_info(self, ctx: NabCtx, name: str):
        """Shows basic information about a Tibia world.

        Shows information like PvP type, online count, server location, vocation distribution, and more."""
        world = await get_world(name)
        if world is None:
            await ctx.send("There's no world with that name.")
            return

        embed = self.get_tibia_embed(world.name, url=world.url)
        if world.status != "Online":
            embed.description = "This world is offline."
            embed.colour = discord.Colour.red()
        else:
            embed.colour = discord.Colour.green()
        embed.add_field(name="Players online", value=str(world.online_count))
        embed.set_footer(text=f"The players online record is {world.record_count}")
        embed.timestamp = world.record_date
        month = calendar.month_name[world.creation_month]
        embed.add_field(name="Created", value=f"{month} {world.creation_year}")

        embed.add_field(name="Location", value=f"{FLAGS.get(world.location.value,'')} {world.location.value}")
        embed.add_field(name="PvP Type", value=f"{PVP.get(world.pvp_type.value,'')} {world.pvp_type.value}")
        if world.premium_only:
            embed.add_field(name="Premium restricted", value=ctx.tick(True))
        if world.transfer_type != TransferType.REGULAR:
            embed.add_field(name="Transfers",
                            value=f"{TRANSFERS.get(world.transfer_type.value,'')} {world.transfer_type.value}")

        voc_counter = Counter(normalize_vocation(char.vocation) for char in world.online_players)
        embed.add_field(name="Vocations distribution",
                        value=f"{voc_counter.get('knight', 0)} {get_voc_emoji('knight')} | "
                              f"{voc_counter.get('druid', 0)} {get_voc_emoji('druid')} | "
                              f"{voc_counter.get('sorcerer', 0)} {get_voc_emoji('sorcerer')} | "
                              f"{voc_counter.get('paladin', 0)} {get_voc_emoji('paladin')} | "
                              f"{voc_counter.get('none', 0)} {get_voc_emoji('none')}",
                        inline=False)

        await ctx.send(embed=embed) 
Example #27
Source File: _strptime.py    From datafari with Apache License 2.0 5 votes vote down vote up
def __calc_month(self):
        # Set self.f_month and self.a_month using the calendar module.
        a_month = [calendar.month_abbr[i].lower() for i in range(13)]
        f_month = [calendar.month_name[i].lower() for i in range(13)]
        self.a_month = a_month
        self.f_month = f_month 
Example #28
Source File: plugin.py    From galaxy-integration-humblebundle with GNU General Public License v3.0 5 votes vote down vote up
def _choice_name_to_slug(subscription_name: str):
        _, type_, year_month = subscription_name.split(' ')
        year, month = year_month.split('-')
        return f'{calendar.month_name[int(month)]}-{year}'.lower() 
Example #29
Source File: events.py    From uqcsbot with MIT License 5 votes vote down vote up
def get_no_result_msg(self):
        if self._weeks is not None:
            return f"There don't appear to be any events in the next *{self._weeks}* weeks"
        elif self._month is not None:
            return f"There don't appear to be any events in *{month_name[self._month]}*"
        else:
            return "There don't appear to be any upcoming events..." 
Example #30
Source File: events.py    From uqcsbot with MIT License 5 votes vote down vote up
def get_header(self):
        if self._full:
            return "List of *all* upcoming events:"
        elif self._weeks is not None:
            return f"Events in the next *{self._weeks} weeks*:"
        elif self._month is not None:
            return f"Events in *{month_name[self._month]}*:"
        else:
            return f"The *next {self._cap} events*:"