本文整理匯總了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())