當前位置: 首頁>>代碼示例>>Python>>正文


Python calendar.month_name方法代碼示例

本文整理匯總了Python中calendar.month_name方法的典型用法代碼示例。如果您正苦於以下問題:Python calendar.month_name方法的具體用法?Python calendar.month_name怎麽用?Python calendar.month_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在calendar的用法示例。


在下文中一共展示了calendar.month_name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: month_name

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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] 
開發者ID:vitorfs,項目名稱:woid,代碼行數:18,代碼來源:calendar_helpers.py

示例2: test_names

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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)) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:23,代碼來源:test_timestamp.py

示例3: report

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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,
    }) 
開發者ID:open-craft,項目名稱:opencraft,代碼行數:26,代碼來源:views.py

示例4: yearly

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:CommvaultEngg,項目名稱:cvpysdk,代碼行數:21,代碼來源:schedules.py

示例5: yearly_relative

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:CommvaultEngg,項目名稱:cvpysdk,代碼行數:25,代碼來源:schedules.py

示例6: span_meta_to_date

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:Buroni,項目名稱:booksoup,代碼行數:20,代碼來源:FbTime.py

示例7: formatmonthname

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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) 
開發者ID:wreckage,項目名稱:django-happenings,代碼行數:19,代碼來源:calendars.py

示例8: _parseReq

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:vertexproject,項目名稱:synapse,代碼行數:23,代碼來源:stormtypes.py

示例9: _parse_req

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:vertexproject,項目名稱:synapse,代碼行數:26,代碼來源:cron.py

示例10: minicalendar

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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} 
開發者ID:linuxsoftware,項目名稱:ls.joyous,代碼行數:23,代碼來源:joyous_tags.py

示例11: test_name

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
def test_name(self):
        # abbreviations
        for i, name in enumerate(calendar.month_abbr[1:]):
            self.assertEqual(MonthSetBuilder().build(name), {i + 1})
            self.assertEqual(MonthSetBuilder().build(name.lower()), {i + 1})
            self.assertEqual(MonthSetBuilder().build(name.upper()), {i + 1})

        # full names
        for i, name in enumerate(calendar.month_name[1:]):
            self.assertEqual(MonthSetBuilder().build(name), {i + 1})
            self.assertEqual(MonthSetBuilder().build(name.lower()), {i + 1})
            self.assertEqual(MonthSetBuilder().build(name.upper()), {i + 1}) 
開發者ID:awslabs,項目名稱:aws-ops-automator,代碼行數:14,代碼來源:test_month_setbuilder.py

示例12: __calc_month

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:8,代碼來源:_strptime.py

示例13: test_names

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
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()

        result_day = data.day_name(time_locale)
        result_month = data.month_name(time_locale)

        # Work around https://github.com/pandas-dev/pandas/issues/22342
        # different normalizations

        if not PY2:
            expected_day = unicodedata.normalize("NFD", expected_day)
            expected_month = unicodedata.normalize("NFD", expected_month)

            result_day = unicodedata.normalize("NFD", result_day,)
            result_month = unicodedata.normalize("NFD", result_month)

        assert result_day == expected_day
        assert result_month == 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)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:36,代碼來源:test_timestamp.py

示例14: determine_league_name

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
def determine_league_name(start_date: datetime.datetime, end_date: datetime.datetime) -> str:
    start_of_end_month_s = '{year}-{month}-01 00:00:00'.format(year=end_date.year, month=end_date.month)
    start_of_end_month = dtutil.parse(start_of_end_month_s, '%Y-%m-%d %H:%M:%S', dtutil.WOTC_TZ).astimezone(dtutil.WOTC_TZ)
    if start_date + datetime.timedelta(weeks=2) < start_of_end_month:
        key_date = start_date
    else:
        key_date = end_date
    return 'League {MM} {YYYY}'.format(MM=calendar.month_name[key_date.month], YYYY=key_date.year) 
開發者ID:PennyDreadfulMTG,項目名稱:Penny-Dreadful-Tools,代碼行數:10,代碼來源:league.py

示例15: format_date

# 需要導入模塊: import calendar [as 別名]
# 或者: from calendar import month_name [as 別名]
def format_date(date):
    '''Convert dates to ISO 8601 (RFC 3339 "full-date") format.'''
    remainder = re.split('(?:\s|&nbsp;)+'.format(WS), date, 1)
    month_name = remainder[0]
    remainder = re.split(',{0}'.format(WS), remainder[1], 1)
    day = remainder[0]
    year = remainder[1]
    month = datetime.date.month # Fallback
    for i in range(12):
        if month_name == calendar.month_name[i]:
            month = i
            break
    return '{0}-{1}-{2}'.format(year, month, day) 
開發者ID:buzzlawless,項目名稱:ynab-live-import,代碼行數:15,代碼來源:parseDiscoverEmail.py


注:本文中的calendar.month_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。