Simple module to parse ISO 8601 dates
`pip install iso8601`
Documentation: https://pyiso8601.readthedocs.org/
PyPI: https://pypi.org/project/iso8601/
Source: https://github.com/micktwomey/pyiso8601
This module parses the most common forms of ISO 8601 date strings (e.g. 2007-01-14T20:34:22+00:00) into datetime objects.
>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>>
See the LICENSE file for the license this package is released under.
If you want more full featured parsing look at:
- https://arrow.readthedocs.io - arrow
- https://pendulum.eustace.io - pendulum
- https://labix.org/python-dateutil - python-dateutil
- https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat - Yes, Python 3 has built in parsing too!
Parsed Formats
==============
You can parse full date + times, or just the date. In both cases a datetime instance is returned but with missing times defaulting to 0, and missing days / months defaulting to 1.
Dates
-----
- YYYY-MM-DD
- YYYYMMDD
- YYYY-MM (defaults to 1 for the day)
- YYYY (defaults to 1 for month and day)
Times
-----
- hh:mm:ss.nn
- hhmmss.nn
- hh:mm (defaults to 0 for seconds)
- hhmm (defaults to 0 for seconds)
- hh (defaults to 0 for minutes and seconds)
Time Zones
----------
- Nothing, will use the default timezone given (which in turn defaults to UTC).
- Z (UTC)
- +/-hh:mm
- +/-hhmm
- +/-hh
Where it Differs From ISO 8601
==============================
Known differences from the ISO 8601 spec:
- You can use a " " (space) instead of T for separating date from time.
- Days and months without a leading 0 (2 vs 02) will be parsed.
- If time zone information is omitted the default time zone given is used (which in turn defaults to UTC). Use a default of None to yield naive datetime instances.
References
==========
- https://en.wikipedia.org/wiki/ISO_8601
- https://www.cl.cam.ac.uk/~mgk25/iso-time.html - simple overview
- https://web.archive.org/web/20090309040208/http://hydracen.com/dx/iso8601.htm - more detailed enumeration of valid formats.
Testing
=======
1. `poetry install`
2. `poetry run nox`
Note that you need all the pythons installed to perform a tox run (see below). pyenv helps hugely, use pyenv install for the versions you need then use 'pyenv local version ...' to link them in (the tox-pyenv plugin will pick them up).
Alternatively, to test only with your current python:
1. `poetry install`
2. `pytest`
Releasing
=========
1. `just prepare-release`
2. `just do-release`
Supported Python Versions
=========================
Tested against:
- Python 3.7
- Python 3.8
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
- PyPy 3
Python 3 versions < 3.7 are untested but should work.
Changes
=======
See `CHANGELOG.md <https://github.com/micktwomey/pyiso8601/blob/main/CHANGELOG.md>`_.
Raw data
{
"_id": null,
"home_page": "https://github.com/micktwomey/pyiso8601",
"name": "iso8601",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Michael Twomey",
"author_email": "mick@twomeylee.name",
"download_url": "https://files.pythonhosted.org/packages/b9/f3/ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15/iso8601-2.1.0.tar.gz",
"platform": null,
"description": "Simple module to parse ISO 8601 dates\n\n`pip install iso8601`\n\nDocumentation: https://pyiso8601.readthedocs.org/\n\nPyPI: https://pypi.org/project/iso8601/\n\nSource: https://github.com/micktwomey/pyiso8601\n\nThis module parses the most common forms of ISO 8601 date strings (e.g. 2007-01-14T20:34:22+00:00) into datetime objects.\n\n>>> import iso8601\n>>> iso8601.parse_date(\"2007-01-25T12:00:00Z\")\ndatetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)\n>>>\n\nSee the LICENSE file for the license this package is released under.\n\nIf you want more full featured parsing look at:\n\n- https://arrow.readthedocs.io - arrow\n- https://pendulum.eustace.io - pendulum\n- https://labix.org/python-dateutil - python-dateutil\n- https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat - Yes, Python 3 has built in parsing too!\n\nParsed Formats\n==============\n\nYou can parse full date + times, or just the date. In both cases a datetime instance is returned but with missing times defaulting to 0, and missing days / months defaulting to 1.\n\nDates\n-----\n\n- YYYY-MM-DD\n- YYYYMMDD\n- YYYY-MM (defaults to 1 for the day)\n- YYYY (defaults to 1 for month and day)\n\nTimes\n-----\n\n- hh:mm:ss.nn\n- hhmmss.nn\n- hh:mm (defaults to 0 for seconds)\n- hhmm (defaults to 0 for seconds)\n- hh (defaults to 0 for minutes and seconds)\n\nTime Zones\n----------\n\n- Nothing, will use the default timezone given (which in turn defaults to UTC).\n- Z (UTC)\n- +/-hh:mm\n- +/-hhmm\n- +/-hh\n\nWhere it Differs From ISO 8601\n==============================\n\nKnown differences from the ISO 8601 spec:\n\n- You can use a \" \" (space) instead of T for separating date from time.\n- Days and months without a leading 0 (2 vs 02) will be parsed.\n- If time zone information is omitted the default time zone given is used (which in turn defaults to UTC). Use a default of None to yield naive datetime instances.\n\nReferences\n==========\n\n- https://en.wikipedia.org/wiki/ISO_8601\n\n- https://www.cl.cam.ac.uk/~mgk25/iso-time.html - simple overview\n\n- https://web.archive.org/web/20090309040208/http://hydracen.com/dx/iso8601.htm - more detailed enumeration of valid formats.\n\nTesting\n=======\n\n1. `poetry install`\n2. `poetry run nox`\n\nNote that you need all the pythons installed to perform a tox run (see below). pyenv helps hugely, use pyenv install for the versions you need then use 'pyenv local version ...' to link them in (the tox-pyenv plugin will pick them up).\n\nAlternatively, to test only with your current python:\n\n1. `poetry install`\n2. `pytest`\n\nReleasing\n=========\n\n1. `just prepare-release`\n2. `just do-release`\n\nSupported Python Versions\n=========================\n\nTested against:\n\n- Python 3.7\n- Python 3.8\n- Python 3.9\n- Python 3.10\n- Python 3.11\n- Python 3.12\n- PyPy 3\n\nPython 3 versions < 3.7 are untested but should work.\n\nChanges\n=======\n\nSee `CHANGELOG.md <https://github.com/micktwomey/pyiso8601/blob/main/CHANGELOG.md>`_.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple module to parse ISO 8601 dates",
"version": "2.1.0",
"project_urls": {
"Documentation": "https://pyiso8601.readthedocs.io/en/latest/",
"Homepage": "https://github.com/micktwomey/pyiso8601",
"Repository": "https://github.com/micktwomey/pyiso8601"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6c0cf37b6a241f0759b7653ffa7213889d89ad49a2b76eb2ddf3b57b2738c347",
"md5": "e3b1014d767f5178e4704b2f6b4e9562",
"sha256": "aac4145c4dcb66ad8b648a02830f5e2ff6c24af20f4f482689be402db2429242"
},
"downloads": -1,
"filename": "iso8601-2.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3b1014d767f5178e4704b2f6b4e9562",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 7545,
"upload_time": "2023-10-03T00:25:32",
"upload_time_iso_8601": "2023-10-03T00:25:32.304896Z",
"url": "https://files.pythonhosted.org/packages/6c/0c/f37b6a241f0759b7653ffa7213889d89ad49a2b76eb2ddf3b57b2738c347/iso8601-2.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b9f3ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15",
"md5": "6e33910eba87066b3be7fcf3d59d16b5",
"sha256": "6b1d3829ee8921c4301998c909f7829fa9ed3cbdac0d3b16af2d743aed1ba8df"
},
"downloads": -1,
"filename": "iso8601-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6e33910eba87066b3be7fcf3d59d16b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 6522,
"upload_time": "2023-10-03T00:25:39",
"upload_time_iso_8601": "2023-10-03T00:25:39.317870Z",
"url": "https://files.pythonhosted.org/packages/b9/f3/ef59cee614d5e0accf6fd0cbba025b93b272e626ca89fb70a3e9187c5d15/iso8601-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-03 00:25:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "micktwomey",
"github_project": "pyiso8601",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "iso8601"
}