Skip to content

Commit

Permalink
Update the docs to remove subset discussion
Browse files Browse the repository at this point in the history
We now support all the forms that other ISO 8601 parsers support
  • Loading branch information
movermeyer committed Nov 30, 2022
1 parent 0f186bb commit 73f9724
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 45 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Fixed: `datetime.tzname` returns a `str` in Python 2.7, not a `unicode`
* Change `METH_VARARGS` to `METH_O`, enhancing performance. ([#130](https://github.com/closeio/ciso8601/pull/130))
* Added support for ISO week dates, ([#139](https://github.com/closeio/ciso8601/pull/139))
* Added support for ordinal dates, ([#140](https://github.com/closeio/ciso8601/pull/140))

# 2.x.x

Expand Down
27 changes: 15 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ ciso8601
Since it's written as a C module, it is much faster than other Python libraries.
Tested with cPython 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11.

.. |datetime.fromisoformat| replace:: ``datetime.fromisoformat``
.. _datetime.fromisoformat: https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat

**Note:** ciso8601 doesn't support the entirety of the ISO 8601 spec; but supports `a superset`_ of what is supported by Python itself (|datetime.fromisoformat|_).

.. _ISO 8601: https://en.wikipedia.org/wiki/ISO_8601
.. _RFC 3339: https://tools.ietf.org/html/rfc3339

.. _`a superset`: https://github.com/closeio/ciso8601#supported-subset-of-iso-8601

(Interested in working on projects like this? `Close`_ is looking for `great engineers`_ to join our team)

.. _Close: https://close.com
Expand Down Expand Up @@ -203,16 +196,16 @@ Tested on Linux 5.15.49-linuxkit using the following modules:
.. </include:benchmark_module_versions.rst>
**Note:** ciso8601 doesn't support the entirety of the ISO 8601 spec; but supports `a superset`_ of what is supported by Python itself (|datetime.fromisoformat|_).


For full benchmarking details (or to run the benchmark yourself), see `benchmarking/README.rst`_

.. _`benchmarking/README.rst`: https://github.com/closeio/ciso8601/blob/master/benchmarking/README.rst

Supported subset of ISO 8601
----------------------------

.. |datetime.fromisoformat| replace:: ``datetime.fromisoformat``
.. _datetime.fromisoformat: https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat

``ciso8601`` only supports a subset of ISO 8601, but supports a superset of what is supported by Python itself (|datetime.fromisoformat|_), and supports the entirety of the `RFC 3339`_ specification.

Date formats
Expand All @@ -233,8 +226,18 @@ The following date formats are supported:
``YYYY-Www`` (week date) ``2009-W01`` ✅
``YYYYWwwD`` (week date) ``2009W011`` ✅
``YYYYWww`` (week date) ``2009W01`` ✅
``YYYY-DDD`` (ordinal date) ``1981-095`` ❌
``YYYYDDD`` (ordinal date) ``1981095`` ❌
``YYYY-DDD`` (ordinal date) ``1981-095`` ✅
``YYYYDDD`` (ordinal date) ``1981095`` ✅
============================= ============== ==================

Uncommon ISO 8601 date formats are not supported:

.. table::
:widths: auto

============================= ============== ==================
Format Example Supported
============================= ============== ==================
``--MM-DD`` (omitted year) ``--04-29`` ❌
``--MMDD`` (omitted year) ``--0429`` ❌
``±YYYYY-MM`` (>4 digit year) ``+10000-04`` ❌
Expand Down
4 changes: 1 addition & 3 deletions benchmarking/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Benchmarking ciso8601
Introduction
------------

``ciso8601``'s goal is to be the world's fastest ISO 8601 datetime parser for Python (**Note:** ciso8601 `only supports a subset of ISO 8601`_).

.. _`only supports a subset of ISO 8601`: https://github.com/closeio/ciso8601#supported-subset-of-iso-8601
``ciso8601``'s goal is to be the world's fastest ISO 8601 datetime parser for Python.

In order to see how we compare, we run benchmarks against each other known ISO 8601 parser.

Expand Down
37 changes: 7 additions & 30 deletions why_ciso8601.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,31 @@ This document aims to describe some considerations to make when choosing a times

- [Do you care about the performance of timestamp parsing?](#do-you-care-about-the-performance-of-timestamp-parsing)
- [Do you need strict RFC 3339 parsing?](#do-you-need-strict-rfc-3339-parsing)
- [Are you OK with the subset of ISO 8601 supported by ciso8601?](#are-you-ok-with-the-subset-of-iso-8601-supported-by-ciso8601)
- [Do you need to support Python \< 3.11?](#do-you-need-to-support-python--311)
- [Do you need to support Python 2.7?](#do-you-need-to-support-python-27)

### Flowchart <!-- omit in toc -->

```mermaid
graph TD;
A[Do you care about the performance of timestamp parsing?]
A--yes-->Y;
A--no-->C;
C[Do you need to support Python 2.7?];
C--yes-->DD
C--yes-->Y
C--no-->E
E[Do you need strict RFC 3339 parsing?];
E--yes-->YY;
E--no-->AA;
AA[Do you care about the performance of timestamp parsing?]
AA--yes-->D;
AA--no-->H;
E--yes-->Y;
E--no-->H;
H[Do you need to support Python < 3.11?]
H--yes-->V;
H--no-->Z;
DD[Are you OK with the subset of ISO 8601 supported by ciso8601?]
DD--no-->WW;
DD--yes-->YY;
D[Are you OK with the subset of ISO 8601 supported by ciso8601?]
D--yes-->Y;
D--no-->W;
V[Use `backports.datetime_fromisoformat`]
W[Use `pendulum.parsing.parse_iso8601`]
WW[Use `pendulum.parsing.parse_iso8601`]
Y[Use `ciso8601`]
YY[Use `ciso8601`]
Z[Use `datetime.fromisoformat`]
```

Expand All @@ -59,17 +47,6 @@ If you really, truly want to use the fastest parser, then `ciso8601` aims to be

RFC 3339 can be (roughly) thought of as a subset of ISO 8601. If you need strict timestamp parsing that will complain if the given timestamp isn't strictly RFC 3339 compliant, then [`ciso8601` has a `parse_rfc3339` method](https://github.com/closeio/ciso8601#strict-rfc-3339-parsing).

## Are you OK with the subset of ISO 8601 supported by ciso8601?

You probably are. `ciso8601` supports [the subset of ISO 8601](https://github.com/closeio/ciso8601#supported-subset-of-iso-8601) that is supported by Python itself.

If not, consider [`pendulum`](https://github.com/sdispater/pendulum)'s `parsing.parse_iso8601` instead:

```python
from pendulum.parsing import parse_iso8601
parse_iso8601(timestamp)
```

## Do you need to support Python < 3.11?

Since Python 3.11, `datetime.fromisoformat` supports parsing nearly any ISO 8601 timestamp, and the cPython implementation is [very performant](https://github.com/closeio/ciso8601#benchmark).
Expand Down

0 comments on commit 73f9724

Please sign in to comment.