当前位置: 首页>>代码示例>>Python>>正文


Python DateTime.isValid方法代码示例

本文整理汇总了Python中lsst.daf.base.DateTime.isValid方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.isValid方法的具体用法?Python DateTime.isValid怎么用?Python DateTime.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lsst.daf.base.DateTime的用法示例。


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

示例1: testMJD

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testMJD(self):
     ts = DateTime(45205.125, DateTime.MJD, DateTime.UTC)
     self.assertEqual(ts.nsecs(DateTime.UTC), 399006000000000000)
     self.assertEqual(ts.nsecs(DateTime.TAI), 399006021000000000)
     self.assertAlmostEqual(ts.get(DateTime.MJD, DateTime.UTC), 45205.125)
     self.assertAlmostEqual(ts.get(DateTime.MJD, DateTime.TAI), 45205.125 + 21.0/86400.0)
     self.assertTrue(ts.isValid())
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:9,代码来源:test_dateTime.py

示例2: testNsecsDefault

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testNsecsDefault(self):
     ts = DateTime(1192755506000000000)
     self.assertEqual(ts.nsecs(DateTime.UTC), 1192755473000000000)
     self.assertEqual(ts.nsecs(DateTime.TAI), 1192755506000000000)
     self.assertEqual(ts.nsecs(), 1192755506000000000)
     self.assertAlmostEqual(ts.get(DateTime.MJD, DateTime.UTC), 54392.040196759262)
     self.assertTrue(ts.isValid())
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:9,代码来源:test_dateTime.py

示例3: testNegative

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
    def testNegative(self):
        ts = DateTime("1969-03-01T00:00:32Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-03-01T00:00:32.000000000Z')
        ts = DateTime("1969-01-01T00:00:00Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-01-01T00:00:00.000000000Z')
        ts = DateTime("1969-01-01T00:00:40Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-01-01T00:00:40.000000000Z')
        ts = DateTime("1969-01-01T00:00:38Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-01-01T00:00:38.000000000Z')
        ts = DateTime("1969-03-01T12:39:45Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-03-01T12:39:45.000000000Z')
        ts = DateTime("1969-03-01T12:39:45.000000001Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-03-01T12:39:45.000000001Z')
        self.assertTrue(ts.isValid())

        # Note slight inaccuracy in UTC-TAI-UTC round-trip
        ts = DateTime("1969-03-01T12:39:45.12345Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-03-01T12:39:45.123449996Z')
        ts = DateTime("1969-03-01T12:39:45.123456Z", DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-03-01T12:39:45.123455996Z')

        ts = DateTime(-1, DateTime.TAI)
        self.assertEqual(ts.toString(ts.UTC), '1969-12-31T23:59:51.999918239Z')
        ts = DateTime(0, DateTime.TAI)
        self.assertEqual(ts.toString(ts.UTC), '1969-12-31T23:59:51.999918240Z')
        ts = DateTime(1, DateTime.TAI)
        self.assertEqual(ts.toString(ts.UTC), '1969-12-31T23:59:51.999918241Z')

        ts = DateTime(-1, DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1969-12-31T23:59:59.999999999Z')
        ts = DateTime(0, DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1970-01-01T00:00:00.000000000Z')
        ts = DateTime(1, DateTime.UTC)
        self.assertEqual(ts.toString(ts.UTC), '1970-01-01T00:00:00.000000001Z')
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:36,代码来源:test_dateTime.py

示例4: testIsoNonUTCBasics

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testIsoNonUTCBasics(self):
     """Test basic ISO string input and output of TAI and TT dates"""
     for scale in (DateTime.TAI, DateTime.TT):
         for dateSep in ("-", ""):  # "-" date separator is optional
             for timeSep in (":", ""):  # ":" time separator is optional
                 for decPt in (".", ","):  # "." or "," may be used as decimal point
                     dateStr = "2009{0}04{0}02T07{1}26{1}39{2}314159265".format(dateSep, timeSep, decPt)
                     ts = DateTime(dateStr, scale)
                     self.assertEqual(ts.toString(scale), "2009-04-02T07:26:39.314159265")
                     self.assertTrue(ts.isValid())
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:12,代码来源:test_dateTime.py

示例5: testInvalid

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testInvalid(self):
     ts = DateTime()
     self.assertFalse(ts.isValid())
     for scale in self.timeScales:
         self.assertEqual(ts.nsecs(scale), DateTime.invalid_nsecs)
         for system in self.dateSystems:
             with self.assertRaises(RuntimeError):
                 ts.get(system, scale)
         with self.assertRaises(RuntimeError):
             ts.gmtime(scale)
         with self.assertRaises(RuntimeError):
             ts.timespec(scale)
         with self.assertRaises(RuntimeError):
             ts.timeval(scale)
         with self.assertRaises(RuntimeError):
             ts.toString(scale)
     self.assertEqual(repr(ts), "DateTime()")
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:19,代码来源:test_dateTime.py

示例6: testIsoNoNSecs

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testIsoNoNSecs(self):
     ts = DateTime("2009-04-02T07:26:39Z", DateTime.UTC)
     self.assertEqual(ts.nsecs(DateTime.TAI), 1238657233000000000)
     self.assertEqual(ts.nsecs(DateTime.UTC), 1238657199000000000)
     self.assertEqual(ts.toString(ts.UTC), "2009-04-02T07:26:39.000000000Z")
     self.assertTrue(ts.isValid())
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:8,代码来源:test_dateTime.py

示例7: testIsoExpanded

# 需要导入模块: from lsst.daf.base import DateTime [as 别名]
# 或者: from lsst.daf.base.DateTime import isValid [as 别名]
 def testIsoExpanded(self):
     ts = DateTime("2009-04-02T07:26:39.314159265Z", DateTime.UTC)
     self.assertEqual(ts.nsecs(DateTime.TAI), 1238657233314159265)
     self.assertEqual(ts.nsecs(DateTime.UTC), 1238657199314159265)
     self.assertEqual(ts.toString(ts.UTC), "2009-04-02T07:26:39.314159265Z")
     self.assertTrue(ts.isValid())
开发者ID:HyperSuprime-Cam,项目名称:daf_base,代码行数:8,代码来源:test_dateTime.py


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