当前位置: 首页>>代码示例>>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;未经允许,请勿转载。