Skip to main content

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

Project description

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')

Copyright © 2020 Niklas Rosenstein

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nr.parsing.date-1.0.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

nr.parsing.date-1.0.0-py3-none-any.whl (10.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page