本文整理汇总了Python中qgis.core.QgsInterval.fromString方法的典型用法代码示例。如果您正苦于以下问题:Python QgsInterval.fromString方法的具体用法?Python QgsInterval.fromString怎么用?Python QgsInterval.fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsInterval
的用法示例。
在下文中一共展示了QgsInterval.fromString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testFromString
# 需要导入模块: from qgis.core import QgsInterval [as 别名]
# 或者: from qgis.core.QgsInterval import fromString [as 别名]
def testFromString(self):
i = QgsInterval.fromString('1 Year 1 Month 1 Week 1 Hour 1 Minute')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 34758060)
i = QgsInterval.fromString('1 Year, 1 Month, 1 Week, 1 Hour, 1 Minute')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 34758060)
i = QgsInterval.fromString('1 Year; 1 Month; 1 Week; 1 Hour; 1 Minute')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 34758060)
i = QgsInterval.fromString('1 Year. 1 Month. 1 Week. 1 Hour. 1 Minute.')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 34758060)
i = QgsInterval.fromString('2 Years')
self.assertTrue(i.isValid())
self.assertEqual(i.years(), 2)
i = QgsInterval.fromString('30 month')
self.assertTrue(i.isValid())
self.assertEqual(i.months(), 30)
i = QgsInterval.fromString(' 40 MONTHS ')
self.assertTrue(i.isValid())
self.assertEqual(i.months(), 40)
i = QgsInterval.fromString('2.5 weeks')
self.assertTrue(i.isValid())
self.assertEqual(i.weeks(), 2.5)
i = QgsInterval.fromString('2.5 WEEK')
self.assertTrue(i.isValid())
self.assertEqual(i.weeks(), 2.5)
i = QgsInterval.fromString('1 Day')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 24 * 60 * 60)
i = QgsInterval.fromString('2 dAys')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 48 * 60 * 60)
i = QgsInterval.fromString('1 hours')
self.assertTrue(i.isValid())
self.assertEqual(i.hours(), 1)
i = QgsInterval.fromString('1.7 HoURS ')
self.assertTrue(i.isValid())
self.assertEqual(i.hours(), 1.7)
i = QgsInterval.fromString('2 minutes')
self.assertTrue(i.isValid())
self.assertEqual(i.minutes(), 2)
i = QgsInterval.fromString('123 MiNuTe ')
self.assertTrue(i.isValid())
self.assertEqual(i.minutes(), 123)
i = QgsInterval.fromString('5 Seconds')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 5)
i = QgsInterval.fromString('5 second')
self.assertTrue(i.isValid())
self.assertEqual(i.seconds(), 5)
i = QgsInterval.fromString('bad')
self.assertFalse(i.isValid())