How to use parsedatetime - 10 common examples

To help you get started, we’ve selected a few parsedatetime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bear / parsedatetime / tests / TestUnits.py View on Github external
def setUp(self):
        self.cal = pdt.Calendar()
        (self.yr, self.mth, self.dy, self.hr,
         self.mn, self.sec, self.wd, self.yd, self.isdst) = time.localtime()
github bear / parsedatetime / tests / TestFrenchLocale.py View on Github external
def setUp(self):
        locale = 'fr_FR'
        self.ptc = pdt.Constants(locale, usePyICU=False)
        self.cal = pdt.Calendar(self.ptc)

        (self.yr, self.mth, self.dy, self.hr,
         self.mn, self.sec, self.wd, self.yd, self.isdst) = time.localtime()

        if self.ptc.localeID != locale:
            raise unittest.SkipTest(
                'Locale not set to fr_FR - check if PyICU is installed')
github bear / parsedatetime / tests / TestLocaleBase.py View on Github external
def setUp(self):
        self.ptc = pdt.Constants('fr_FR', usePyICU=True)
        self.cal = pdt.Calendar(self.ptc)

        (self.yr, self.mth, self.dy, self.hr,
         self.mn, self.sec, self.wd, self.yd, self.isdst) = time.localtime()

        if self.ptc.localeID != 'fr_FR':
            raise unittest.SkipTest(
                'Locale not set to fr_FR - check if PyICU is installed')
github bear / parsedatetime / tests / TestContext.py View on Github external
def testSources(self):
        self.assertEqual(self.cal.parse('afternoon 5pm')[1],
                         pdtContext(pdtContext.ACU_HALFDAY |
                                    pdtContext.ACU_HOUR))

        self.assertEqual(self.cal.parse('morning')[1],
                         pdtContext(pdtContext.ACU_HALFDAY))

        self.assertEqual(self.cal.parse('night', version=1)[1], 2)
github bear / parsedatetime / tests / TestContext.py View on Github external
def testContext(self):
        self.assertEqual(self.cal.parse('5 min from now')[1],
                         pdtContext(pdtContext.ACU_MIN | pdtContext.ACU_NOW))
        self.assertEqual(self.cal.parse('5 min from now',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 2)
        self.assertEqual(self.cal.parse('7/11/2015')[1],
                         pdtContext(pdtContext.ACU_YEAR |
                                    pdtContext.ACU_MONTH | pdtContext.ACU_DAY))
        self.assertEqual(self.cal.parse('7/11/2015',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 1)
        self.assertEqual(self.cal.parse('14/32/2015')[1],
                         pdtContext(0))
        self.assertEqual(self.cal.parse('25:23')[1],
                         pdtContext())
github bear / parsedatetime / tests / TestContext.py View on Github external
def testContext(self):
        self.assertEqual(self.cal.parse('5 min from now')[1],
                         pdtContext(pdtContext.ACU_MIN | pdtContext.ACU_NOW))
        self.assertEqual(self.cal.parse('5 min from now',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 2)
        self.assertEqual(self.cal.parse('7/11/2015')[1],
                         pdtContext(pdtContext.ACU_YEAR |
                                    pdtContext.ACU_MONTH | pdtContext.ACU_DAY))
        self.assertEqual(self.cal.parse('7/11/2015',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 1)
        self.assertEqual(self.cal.parse('14/32/2015')[1],
                         pdtContext(0))
        self.assertEqual(self.cal.parse('25:23')[1],
                         pdtContext())
github bear / parsedatetime / tests / TestContext.py View on Github external
def testSources(self):
        self.assertEqual(self.cal.parse('afternoon 5pm')[1],
                         pdtContext(pdtContext.ACU_HALFDAY |
                                    pdtContext.ACU_HOUR))

        self.assertEqual(self.cal.parse('morning')[1],
                         pdtContext(pdtContext.ACU_HALFDAY))

        self.assertEqual(self.cal.parse('night', version=1)[1], 2)
github bear / parsedatetime / tests / TestContext.py View on Github external
def testContext(self):
        self.assertEqual(self.cal.parse('5 min from now')[1],
                         pdtContext(pdtContext.ACU_MIN | pdtContext.ACU_NOW))
        self.assertEqual(self.cal.parse('5 min from now',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 2)
        self.assertEqual(self.cal.parse('7/11/2015')[1],
                         pdtContext(pdtContext.ACU_YEAR |
                                    pdtContext.ACU_MONTH | pdtContext.ACU_DAY))
        self.assertEqual(self.cal.parse('7/11/2015',
                                        version=pdt.VERSION_FLAG_STYLE)[1], 1)
        self.assertEqual(self.cal.parse('14/32/2015')[1],
                         pdtContext(0))
        self.assertEqual(self.cal.parse('25:23')[1],
                         pdtContext())
github bear / parsedatetime / tests / TestContext.py View on Github external
def setUp(self):
        self.cal = pdt.Calendar(version=pdt.VERSION_CONTEXT_STYLE)
        (self.yr, self.mth, self.dy, self.hr, self.mn,
         self.sec, self.wd, self.yd, self.isdst) = time.localtime()
github bear / parsedatetime / tests / TestDelta.py View on Github external
def setUp(self):
        self.cal = pdt.Calendar(version=pdt.VERSION_CONTEXT_STYLE)
        self.source = (2017, 1, 1, 7, 1, 2, 6, 1, 1)