How to use the ciso8601.parse_rfc3339 function in ciso8601

To help you get started, we’ve selected a few ciso8601 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 closeio / ciso8601 / tests.py View on Github external
"2018-01-02",  # Missing mandatory time
                "2018-01-02T03",  # Missing mandatory minute and second
                "2018-01-02T03Z",  # Missing mandatory minute and second
                "2018-01-02T03:04",  # Missing mandatory minute and second
                "2018-01-02T03:04Z",  # Missing mandatory minute and second
                "2018-01-02T03:04:01+04",  # Missing mandatory offset minute
                "2018-01-02T03:04:05",  # Missing mandatory offset
                "2018-01-02T03:04:05.12345",  # Missing mandatory offset
                "2018-01-02T24:00:00Z",  # 24:00:00 is not valid in RFC 3339
                '20180102T03:04:05-12:34',  # Missing mandatory date separators
                '2018-01-02T030405-12:34',  # Missing mandatory time separators
                '2018-01-02T03:04:05-1234',  # Missing mandatory offset separator
                '2018-01-02T03:04:05,12345Z'  # Invalid comma fractional second separator
        ]:
            with self.assertRaisesRegex(ValueError, r"RFC 3339", msg="Timestamp '{0}' was supposed to be invalid, but parsing it didn't raise ValueError.".format(timestamp)):
                ciso8601.parse_rfc3339(timestamp)
github closeio / ciso8601 / tests.py View on Github external
Validate that valid RFC 3339 datetimes are parseable by parse_rfc3339
        and produce the same result as parse_datetime.
        """
        for string in [
                '2018-01-02T03:04:05Z',
                '2018-01-02t03:04:05z',
                '2018-01-02 03:04:05z',
                '2018-01-02T03:04:05+00:00',
                '2018-01-02T03:04:05-00:00',
                '2018-01-02T03:04:05.12345Z',
                '2018-01-02T03:04:05+01:23',
                '2018-01-02T03:04:05-12:34',
                '2018-01-02T03:04:05-12:34',
        ]:
            self.assertEqual(ciso8601.parse_datetime(string),
                             ciso8601.parse_rfc3339(string))

ciso8601

Fast ISO8601 date time parser for Python written in C

MIT
Latest version published 13 days ago

Package Health Score

88 / 100
Full package analysis

Similar packages