• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python parser.parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nldate.parser.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_every_weekday

    def test_every_weekday(self):
        r = parse('every weekday', default=datetime(2011, 5, 10))
        self.assertEqual(
            r.between(datetime(2011, 5, 10), datetime(2011, 5, 20)),
            [
                datetime(2011, 5, 11, 0, 0),
                datetime(2011, 5, 12, 0, 0),
                datetime(2011, 5, 13, 0, 0),
                datetime(2011, 5, 16, 0, 0),
                datetime(2011, 5, 17, 0, 0),
                datetime(2011, 5, 18, 0, 0),
                datetime(2011, 5, 19, 0, 0)
            ]
        )

        r = parse('every wday', default=datetime(2011, 5, 10))
        self.assertEqual(
            r.between(datetime(2011, 5, 10), datetime(2011, 5, 20)),
            [
                datetime(2011, 5, 11, 0, 0),
                datetime(2011, 5, 12, 0, 0),
                datetime(2011, 5, 13, 0, 0),
                datetime(2011, 5, 16, 0, 0),
                datetime(2011, 5, 17, 0, 0),
                datetime(2011, 5, 18, 0, 0),
                datetime(2011, 5, 19, 0, 0)
            ]
        )
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:28,代码来源:test_parser.py


示例2: testIncreasingCTime

 def testIncreasingCTime(self):
     # This test will check 200 different years, every month, every day,
     # every hour, every minute, every second, and every weekday, using
     # a delta of more or less 1 year, 1 month, 1 day, 1 minute and
     # 1 second.
     delta = timedelta(days=365 + 31 + 1, seconds=1 + 60 + 60 * 60)
     dt = datetime(1900, 1, 1, 0, 0, 0, 0)
     for i in range(200):
         self.assertEqual(parse(dt.ctime()), dt)
         dt += delta
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:10,代码来源:test_parser.py


示例3: testMicrosecondPrecisionErrorReturns

 def testMicrosecondPrecisionErrorReturns(self):
     # One more precision issue, discovered by Eric Brown.  This should
     # be the last one, as we're no longer using floating points.
     data = [
         100001, 100000, 99999, 99998,
         10001, 10000, 9999, 9998,
         1001, 1000, 999, 998,
         101, 100, 99, 98
     ]
     for ms in data:
         dt = datetime(2008, 2, 27, 21, 26, 1, ms)
         self.assertEquals(parse(dt.isoformat()), dt)
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:12,代码来源:test_parser.py


示例4: test_every_day_1pm

 def test_every_day_1pm(self):
     r = parse('every day at 1pm', default=datetime(2011, 5, 10))
     self.assertEqual(
         r.between(datetime(2011, 5, 10), datetime(2011, 5, 15)),
         [
             datetime(2011, 5, 10, 13, 0),
             datetime(2011, 5, 11, 13, 0),
             datetime(2011, 5, 12, 13, 0),
             datetime(2011, 5, 13, 13, 0),
             datetime(2011, 5, 14, 13, 0)
         ]
     )
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:12,代码来源:test_parser.py


示例5: test_every_mon_fri_20_pm

 def test_every_mon_fri_20_pm(self):
     r = parse('every mon, fri at 20:00', default=datetime(2011, 5, 10))
     self.assertEqual(
         r.between(datetime(2011, 5, 10), datetime(2011, 6, 15)),
         [
             datetime(2011, 5, 13, 20, 0),
             datetime(2011, 5, 16, 20, 0),
             datetime(2011, 5, 20, 20, 0),
             datetime(2011, 5, 23, 20, 0),
             datetime(2011, 5, 27, 20, 0),
             datetime(2011, 5, 30, 20, 0),
             datetime(2011, 6, 3, 20, 0),
             datetime(2011, 6, 6, 20, 0),
             datetime(2011, 6, 10, 20, 0),
             datetime(2011, 6, 13, 20, 0)
         ]
     )
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:17,代码来源:test_parser.py


示例6: test_complex_timeframe

 def test_complex_timeframe(self):
     values = parse(
         'every monday weekly from July 4 12h, 1974 to Oct 2 1974'
     )
     self.assertEqual(
         list(values),
         [
             datetime(1974, 7, 8, 12, 0),
             datetime(1974, 7, 15, 12, 0),
             datetime(1974, 7, 22, 12, 0),
             datetime(1974, 7, 29, 12, 0),
             datetime(1974, 8, 5, 12, 0),
             datetime(1974, 8, 12, 12, 0),
             datetime(1974, 8, 19, 12, 0),
             datetime(1974, 8, 26, 12, 0),
             datetime(1974, 9, 2, 12, 0),
             datetime(1974, 9, 9, 12, 0),
             datetime(1974, 9, 16, 12, 0),
             datetime(1974, 9, 23, 12, 0),
             datetime(1974, 9, 30, 12, 0)
         ]
     )
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:22,代码来源:test_parser.py


示例7: testRandomFormat32

 def testRandomFormat32(self):
     self.assertEqual(parse("01h02s", default=self.default),
                      datetime(2003, 9, 25, 1, 0, 2))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例8: testRandomFormat30

 def testRandomFormat30(self):
     self.assertEqual(parse("01h02m03", default=self.default),
                      datetime(2003, 9, 25, 1, 2, 3))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例9: testRandomFormat19

 def testRandomFormat19(self):
     self.assertEqual(parse("Mon Jan  2 04:24:27 1995"),
                      datetime(1995, 1, 2, 4, 24, 27))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例10: test_every_day

 def test_every_day(self):
     r = parse('ev day', default=datetime(2003, 9, 9))
     self.assertEqual(r.between(datetime(2003, 9, 10),
                                datetime(2003, 9, 15)),
                      [datetime(2003, 9, 11), datetime(2003, 9, 12),
                       datetime(2003, 9, 13), datetime(2003, 9, 14)])
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:6,代码来源:test_parser.py


示例11: testRandomFormat14

 def testRandomFormat14(self):
     self.assertEqual(parse("12h 01m02s am", default=self.default),
                      datetime(2003, 9, 25, 0, 1, 2))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例12: testIncreasingISOFormat

 def testIncreasingISOFormat(self):
     delta = timedelta(days=365 + 31 + 1, seconds=1 + 60 + 60 * 60)
     dt = datetime(1900, 1, 1, 0, 0, 0, 0)
     for i in range(200):
         self.assertEqual(parse(dt.isoformat()), dt)
         dt += delta
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:6,代码来源:test_parser.py


示例13: testRandomFormat35

 def testRandomFormat35(self):
     self.assertEqual(parse("2004 10 Apr 11h30m", default=self.default),
                      datetime(2004, 4, 10, 11, 30))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例14: testRandomFormat24

 def testRandomFormat24(self):
     self.assertEqual(parse("0:00 PM, PST", default=self.default,
                            ignoretz=True),
                      datetime(2003, 9, 25, 12, 0))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:4,代码来源:test_parser.py


示例15: testRandomFormat23

 def testRandomFormat23(self):
     self.assertEqual(parse("950404 122212"),
                      datetime(1995, 4, 4, 12, 22, 12))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例16: testRandomFormat22

 def testRandomFormat22(self):
     self.assertEqual(parse("Jan 1 1999 11:23:34.578"),
                      datetime(1999, 1, 1, 11, 23, 34, 578000))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例17: testRandomFormat21

 def testRandomFormat21(self):
     self.assertEqual(parse("04.04.95 00:22"),
                      datetime(1995, 4, 4, 0, 22))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例18: testRandomFormat20

 def testRandomFormat20(self):
     self.assertEqual(parse("Tue Apr 4 00:22:12 PDT 1995", ignoretz=True),
                      datetime(1995, 4, 4, 0, 22, 12))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例19: testRandomFormat33

 def testRandomFormat33(self):
     self.assertEqual(parse("01m02", default=self.default),
                      datetime(2003, 9, 25, 0, 1, 2))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py


示例20: testRandomFormat25

 def testRandomFormat25(self):
     self.assertEqual(parse("12:08 PM", default=self.default),
                      datetime(2003, 9, 25, 12, 8))
开发者ID:EnTeQuAk,项目名称:nldate,代码行数:3,代码来源:test_parser.py



注:本文中的nldate.parser.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nlmmanipulate.NlmManipulate类代码示例发布时间:2022-05-27
下一篇:
Python Concepts.Concepts类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap