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


Python settings.DATE_FORMAT屬性代碼示例

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


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

示例1: format_as_response

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def format_as_response(self, *args):
        unknown = {'course_id': None, 'count': 0, 'date': None,
                   'country': {'alpha2': None, 'alpha3': None, 'name': country.UNKNOWN_COUNTRY_CODE}}

        for arg in args:
            if arg.country.name == country.UNKNOWN_COUNTRY_CODE:
                unknown['course_id'] = arg.course_id
                unknown['date'] = arg.date.strftime(settings.DATE_FORMAT)
                unknown['count'] += arg.count
                unknown['created'] = arg.created.strftime(settings.DATETIME_FORMAT)

        args = [arg for arg in args if arg.country != country.UNKNOWN_COUNTRY]
        args = sorted(args, key=lambda item: (item.date, item.course_id, item.country.alpha3))

        response = [unknown]
        response += [
            {'course_id': six.text_type(ce.course_id), 'count': ce.count,
             'date': ce.date.strftime(settings.DATE_FORMAT),
             'country': {'alpha2': ce.country.alpha2, 'alpha3': ce.country.alpha3, 'name': ce.country.name},
             'created': ce.created.strftime(settings.DATETIME_FORMAT)} for ce in args
        ]

        return response 
開發者ID:edx,項目名稱:edx-analytics-data-api,代碼行數:25,代碼來源:test_courses.py

示例2: _to_text

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def _to_text(self, fieldsubmission=None, format=settings.DATE_FORMAT):
        if fieldsubmission.data['info']:
            d = datetime.datetime.strptime(fieldsubmission.data['info'], '%Y-%m-%d').date()
            return escape(defaultfilters.date(d, format))
        else:
            return 'not entered' 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:8,代碼來源:other.py

示例3: date

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def date(value, arg=None):
    """Formats a date according to the given format."""
    if value in (None, ''):
        return ''
    if arg is None:
        arg = settings.DATE_FORMAT
    try:
        return formats.date_format(value, arg)
    except AttributeError:
        try:
            return format(value, arg)
        except AttributeError:
            return '' 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:15,代碼來源:defaultfilters.py

示例4: format_last_updated_date_and_time

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def format_last_updated_date_and_time(d):
        return {'update_date': dateformat.format(d, settings.DATE_FORMAT),
                'update_time': dateformat.format(d, settings.TIME_FORMAT)} 
開發者ID:edx,項目名稱:edx-analytics-dashboard,代碼行數:5,代碼來源:__init__.py

示例5: parse_date

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def parse_date(self, date, timezone):
        if date:
            try:
                date = datetime.datetime.strptime(date, settings.DATETIME_FORMAT)
            except ValueError:
                date = datetime.datetime.strptime(date, settings.DATE_FORMAT)
            date = make_aware(date, timezone)
        return date 
開發者ID:edx,項目名稱:edx-analytics-data-api,代碼行數:10,代碼來源:courses.py

示例6: assertIntervalFilteringWorks

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def assertIntervalFilteringWorks(self, expected_response, course_id, start_date, end_date):
        # If start date is after date of existing data, return a 404
        date = (start_date + datetime.timedelta(days=30)).strftime(settings.DATETIME_FORMAT)
        response = self.authenticated_get(
            '%scourses/%s%s?start_date=%s' % (self.api_root_path, course_id, self.path, date))
        self.assertEqual(response.status_code, 404)

        # If end date is before date of existing data, return a 404
        date = (start_date - datetime.timedelta(days=30)).strftime(settings.DATETIME_FORMAT)
        response = self.authenticated_get(
            '%scourses/%s%s?end_date=%s' % (self.api_root_path, course_id, self.path, date))
        self.assertEqual(response.status_code, 404)

        # If data falls in date range, data should be returned
        start = start_date.strftime(settings.DATETIME_FORMAT)
        end = end_date.strftime(settings.DATETIME_FORMAT)
        response = self.authenticated_get('%scourses/%s%s?start_date=%s&end_date=%s' % (
            self.api_root_path, course_id, self.path, start, end))
        self.assertEqual(response.status_code, 200)
        self.assertListEqual(response.data, expected_response)

        # Passing dates in DATE_FORMAT still works
        start = start_date.strftime(settings.DATE_FORMAT)
        end = end_date.strftime(settings.DATE_FORMAT)
        response = self.authenticated_get('%scourses/%s%s?start_date=%s&end_date=%s' % (
            self.api_root_path, course_id, self.path, start, end))
        self.assertEqual(response.status_code, 200)
        self.assertListEqual(response.data, expected_response)


# pylint: disable=abstract-method 
開發者ID:edx,項目名稱:edx-analytics-data-api,代碼行數:33,代碼來源:test_courses.py

示例7: serialize_enrollment

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DATE_FORMAT [as 別名]
def serialize_enrollment(self, enrollment):
        return {
            'created': enrollment.created.strftime(settings.DATETIME_FORMAT),
            'course_id': six.text_type(enrollment.course_id),
            'date': enrollment.date.strftime(settings.DATE_FORMAT),
            enrollment.cleaned_gender: enrollment.count
        } 
開發者ID:edx,項目名稱:edx-analytics-data-api,代碼行數:9,代碼來源:test_courses.py


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