Skip to main content

nr.parsing.date

A fast, regular-expression based library for parsing dates, plus support for ISO 8601 durations.

Requirements

  • Python 3.6+

Supported Date & Time Formats

  • %Y – 4 digit year
  • %m – 2 digit month
  • %d – 2 digit day
  • %H – 2 digit hour
  • %M – 2 digit minute
  • %S – 2 digit second
  • %f – arbitrary precision milliseconds
  • %z – timezone offset ([+-]\d\d:?\d\d offset or Z for UTC)

Built-in format collections

  • ISO_8601 (see ISO 8601 on Wikipedia)
  • JAVA_OFFSET_DATETIME (see OffsetDateTime class on the Java 8 API documentation)

Features

  • Easily extensible to support more date/time format options
  • Date/time formats can use an extended regex-style mode to mark format options as optional (e.g. the two formats %Y and %Y-%m can be expressed in a single regex-style format string as %Y(-%m)?)

Quickstart

from nr.parsing.date import duration, ISO_8601
ISO_8601.parse('2021-04-21T10:13:00.124+0000')
duration.parse('P3Y6M4DT12H30M5S')

Benchmark

The below benchmark compares the performance of testing various format-strings for ISO-8601 dates using the standard library, dateutil.parser.parse(), dateutil.parser.isoparse() and the nr.parsing.date.ISO_8601.parse_datetime() function.

Conclusion: Faster than the standard library but with the same flexibility (except for the missing support for most uncommon format options).

asv run
· Creating environments
· Discovering benchmarks
· Running 5 total benchmarks (1 commits * 1 environments * 5 benchmarks)
[  0.00%] · For nr.parsing.date commit dd35e795 <develop>:
[  0.00%] ·· Benchmarking virtualenv-py3.8-pandas-python-dateutil
[ 10.00%] ··· Running (benchmarks.DatetimeParsingSuite.time_datetime_datetime_strptime--).....
[ 60.00%] ··· benchmarks.DatetimeParsingSuite.time_datetime_datetime_strptime                                     2.22±0.3ms
[ 70.00%] ··· benchmarks.DatetimeParsingSuite.time_datetime_datetime_strptime_reversed                           2.12±0.08ms
[ 80.00%] ··· benchmarks.DatetimeParsingSuite.time_dateutil_parser_isoparse                                      1.46±0.02ms
[ 90.00%] ··· benchmarks.DatetimeParsingSuite.time_dateutil_parser_parse                                          2.77±0.1ms
[100.00%] ··· benchmarks.DatetimeParsingSuite.time_nr_parsing_date_ISO_8601_parse_datetime                       1.62±0.03ms

Copyright © 2020 Niklas Rosenstein

Metadata

Release files for nr.parsing.date 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nr.parsing.date 1.0.3
File Size Uploaded
nr.parsing.date-1.0.3.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nr.parsing.date 1.0.3
File Interpreter ABI Platform
nr.parsing.date-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / nr.parsing.date-1.0.3.tar.gz

Download URL nr.parsing.date-1.0.3.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dbd4fe953c2846a8d2e454c760049e262f302f43e5193705dc0abb794af6b3d7
BLAKE2b-256 checksum
How to use checksums
d2676bc0447b2ffc13feaca12b0180e1ce36c356d02f6a256eb2b60e84c0ba19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.5

Release files / nr.parsing.date-1.0.3-py3-none-any.whl

Download URL nr.parsing.date-1.0.3-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e14541c9596014d5a631031be725dc303ff78062ffdc5b34a30712faf11a914
BLAKE2b-256 checksum
How to use checksums
8d09c98add9cc28c896fae8383b2291e9e418f40d56a9714a647b7edb89da844
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page