本文整理汇总了Python中spyne.protocol.ProtocolBase.strftime方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolBase.strftime方法的具体用法?Python ProtocolBase.strftime怎么用?Python ProtocolBase.strftime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyne.protocol.ProtocolBase
的用法示例。
在下文中一共展示了ProtocolBase.strftime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_strftime
# 需要导入模块: from spyne.protocol import ProtocolBase [as 别名]
# 或者: from spyne.protocol.ProtocolBase import strftime [as 别名]
def test_custom_strftime(self):
s = ProtocolBase.strftime(datetime.date(1800, 9, 23),
"%Y has the same days as 1980 and 2008")
if s != "1800 has the same days as 1980 and 2008":
raise AssertionError(s)
print("Testing all day names from 0001/01/01 until 2000/08/01")
# Get the weekdays. Can't hard code them; they could be
# localized.
days = []
for i in range(1, 10):
days.append(datetime.date(2000, 1, i).strftime("%A"))
nextday = {}
for i in range(8):
nextday[days[i]] = days[i + 1]
startdate = datetime.date(1, 1, 1)
enddate = datetime.date(2000, 8, 1)
prevday = ProtocolBase.strftime(startdate, "%A")
one_day = datetime.timedelta(1)
testdate = startdate + one_day
while testdate < enddate:
if (testdate.day == 1 and testdate.month == 1 and
(testdate.year % 100 == 0)):
print("Testing century", testdate.year)
day = ProtocolBase.strftime(testdate, "%A")
if nextday[prevday] != day:
raise AssertionError(str(testdate))
prevday = day
testdate = testdate + one_day