本文整理汇总了Python中memacs.lib.orgformat.OrgFormat.date方法的典型用法代码示例。如果您正苦于以下问题:Python OrgFormat.date方法的具体用法?Python OrgFormat.date怎么用?Python OrgFormat.date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类memacs.lib.orgformat.OrgFormat
的用法示例。
在下文中一共展示了OrgFormat.date方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_utc_time
# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import date [as 别名]
def test_utc_time(self):
os.environ['TZ'] = "Europe/Vienna"
time.tzset()
self.assertEqual(
OrgFormat.date(
OrgFormat.datetupelutctimestamp("20111219T205510Z"), True
),
"<2011-12-19 Mon 21:55>"
)
self.assertEqual(
OrgFormat.date(
OrgFormat.datetupelutctimestamp("20111219T205510"),
True
),
"<2011-12-19 Mon 20:55>")
self.assertEqual(
OrgFormat.date(OrgFormat.datetupelutctimestamp("20111219"), False),
"<2011-12-19 Mon>"
)
self.assertEqual(
OrgFormat.date(OrgFormat.datetupelutctimestamp("18991230"), False),
"<1899-12-30 Sat>"
)
示例2: test_date
# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import date [as 别名]
def test_date(self):
"""
test Org date
"""
# testing tuples
t = time.strptime("2011-11-02T20:38", "%Y-%m-%dT%H:%M")
date = OrgFormat.date(t)
datetime = OrgFormat.date(t, show_time=True)
self.assertEqual("<2011-11-02 Wed>", date, "date error")
self.assertEqual("<2011-11-02 Wed 20:38>", datetime, "datetime error")
示例3: test_date
# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import date [as 别名]
def test_date(self):
"""
test Org date
"""
# testing time.struct_time
t = time.strptime("2011-11-02T20:38", "%Y-%m-%dT%H:%M")
mydate = OrgFormat.date(t)
mydatetime = OrgFormat.date(t, show_time=True)
self.assertEqual("<2011-11-02 Wed>", mydate, "date error")
self.assertEqual("<2011-11-02 Wed 20:38>", mydatetime, "datetime error")
# testing datetime.datetime
t = datetime.datetime(2018, 9, 22, hour=12, minute=55, second=59)
mydate = OrgFormat.date(t)
mydatetime = OrgFormat.date(t, show_time=True)
self.assertEqual("<2018-09-22 Sat>", mydate, "date error")
self.assertEqual("<2018-09-22 Sat 12:55>", mydatetime, "datetime error")
示例4: test_date
# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import date [as 别名]
def test_date(self):
## fixed day:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,0,0,0,0,0,0])),
u'<1980-12-31 Wed>' )
## fixed time with seconds:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,23,59,58,0,0,0]), 'foo'),
u'<1980-12-31 Wed 23:59>' ) ## seconds are not (yet) defined in Org-mode
## fixed time without seconds:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,23,59,0,0,0,0]), 'foo'),
u'<1980-12-31 Wed 23:59>' )
YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
hhmmss = time.strftime('%H:%M', time.localtime()) ## seconds are not (yet) defined in Org-mode
## simple form with current day:
self.assertEqual(
OrgFormat.date(time.localtime()),
u'<' + YYYYMMDDwday + u'>' )
## show_time parameter not named:
self.assertEqual(
OrgFormat.date(time.localtime(), True),
u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
## show_time parameter named:
self.assertEqual(
OrgFormat.date(time.localtime(), show_time=True),
u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
示例5: test_date
# 需要导入模块: from memacs.lib.orgformat import OrgFormat [as 别名]
# 或者: from memacs.lib.orgformat.OrgFormat import date [as 别名]
def test_date(self):
## fixed day:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,0,0,0,0,0,0])),
u'<1980-12-31 Mon>' ) ## however, it was a Wednesday
## fixed time with seconds:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,23,59,58,0,0,0]), 'foo'),
u'<1980-12-31 Mon 23:59:58>' ) ## however, it was a Wednesday
## fixed time without seconds:
self.assertEqual(
OrgFormat.date(time.struct_time([1980,12,31,23,59,0,0,0,0]), 'foo'),
u'<1980-12-31 Mon 23:59>' ) ## however, it was a Wednesday
YYYYMMDDwday = time.strftime('%Y-%m-%d %a', time.localtime())
hhmmss = time.strftime('%H:%M:%S', time.localtime())
## simple form with current day:
self.assertEqual(
OrgFormat.date(time.localtime()),
u'<' + YYYYMMDDwday + u'>' )
## show_time parameter not named:
self.assertEqual(
OrgFormat.date(time.localtime(), True),
u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )
## show_time parameter named:
self.assertEqual(
OrgFormat.date(time.localtime(), show_time=True),
u'<' + YYYYMMDDwday + u' ' + hhmmss + u'>' )