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


Python locale._weekdays方法代碼示例

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


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

示例1: test_format_date

# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import _weekdays [as 別名]
def test_format_date(self):
        locale = tornado.locale.get('en_US')
        date = datetime.datetime(2013, 4, 28, 18, 35)
        self.assertEqual(locale.format_date(date, full_format=True),
                         'April 28, 2013 at 6:35 pm')

        self.assertEqual(locale.format_date(datetime.datetime.utcnow() - datetime.timedelta(seconds=2), full_format=False),
                         '2 seconds ago')
        self.assertEqual(locale.format_date(datetime.datetime.utcnow() - datetime.timedelta(minutes=2), full_format=False),
                         '2 minutes ago')
        self.assertEqual(locale.format_date(datetime.datetime.utcnow() - datetime.timedelta(hours=2), full_format=False),
                         '2 hours ago')

        now = datetime.datetime.utcnow()
        self.assertEqual(locale.format_date(now - datetime.timedelta(days=1), full_format=False, shorter=True),
                         'yesterday')

        date = now - datetime.timedelta(days=2)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         locale._weekdays[date.weekday()])

        date = now - datetime.timedelta(days=300)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         '%s %d' % (locale._months[date.month - 1], date.day))

        date = now - datetime.timedelta(days=500)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         '%s %d, %d' % (locale._months[date.month - 1], date.day, date.year)) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:30,代碼來源:locale_test.py

示例2: test_format_date

# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import _weekdays [as 別名]
def test_format_date(self):
        locale = tornado.locale.get('en_US')
        date = datetime.datetime(2013, 4, 28, 18, 35)
        self.assertEqual(locale.format_date(date, full_format=True),
                         'April 28, 2013 at 6:35 pm')

        now = datetime.datetime.utcnow()

        self.assertEqual(locale.format_date(now - datetime.timedelta(seconds=2), full_format=False),
                         '2 seconds ago')
        self.assertEqual(locale.format_date(now - datetime.timedelta(minutes=2), full_format=False),
                         '2 minutes ago')
        self.assertEqual(locale.format_date(now - datetime.timedelta(hours=2), full_format=False),
                         '2 hours ago')

        self.assertEqual(locale.format_date(now - datetime.timedelta(days=1),
                                            full_format=False, shorter=True), 'yesterday')

        date = now - datetime.timedelta(days=2)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         locale._weekdays[date.weekday()])

        date = now - datetime.timedelta(days=300)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         '%s %d' % (locale._months[date.month - 1], date.day))

        date = now - datetime.timedelta(days=500)
        self.assertEqual(locale.format_date(date, full_format=False, shorter=True),
                         '%s %d, %d' % (locale._months[date.month - 1], date.day, date.year)) 
開發者ID:tp4a,項目名稱:teleport,代碼行數:31,代碼來源:locale_test.py

示例3: test_format_date

# 需要導入模塊: from tornado import locale [as 別名]
# 或者: from tornado.locale import _weekdays [as 別名]
def test_format_date(self):
        locale = tornado.locale.get("en_US")
        date = datetime.datetime(2013, 4, 28, 18, 35)
        self.assertEqual(
            locale.format_date(date, full_format=True), "April 28, 2013 at 6:35 pm"
        )

        now = datetime.datetime.utcnow()

        self.assertEqual(
            locale.format_date(now - datetime.timedelta(seconds=2), full_format=False),
            "2 seconds ago",
        )
        self.assertEqual(
            locale.format_date(now - datetime.timedelta(minutes=2), full_format=False),
            "2 minutes ago",
        )
        self.assertEqual(
            locale.format_date(now - datetime.timedelta(hours=2), full_format=False),
            "2 hours ago",
        )

        self.assertEqual(
            locale.format_date(
                now - datetime.timedelta(days=1), full_format=False, shorter=True
            ),
            "yesterday",
        )

        date = now - datetime.timedelta(days=2)
        self.assertEqual(
            locale.format_date(date, full_format=False, shorter=True),
            locale._weekdays[date.weekday()],
        )

        date = now - datetime.timedelta(days=300)
        self.assertEqual(
            locale.format_date(date, full_format=False, shorter=True),
            "%s %d" % (locale._months[date.month - 1], date.day),
        )

        date = now - datetime.timedelta(days=500)
        self.assertEqual(
            locale.format_date(date, full_format=False, shorter=True),
            "%s %d, %d" % (locale._months[date.month - 1], date.day, date.year),
        ) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:48,代碼來源:locale_test.py


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