本文整理匯總了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))
示例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))
示例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),
)