pyRFC3339 2.1.0__tar.gz → 2.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/CHANGES.rst +19 -0
  2. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/LICENSE.txt +1 -1
  3. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/PKG-INFO +24 -11
  4. pyrfc3339-2.1.2/README.rst +57 -0
  5. pyrfc3339-2.1.2/docs/requirements.txt +3 -0
  6. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/conf.py +50 -55
  7. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/doc.rst +0 -1
  8. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyRFC3339.egg-info/PKG-INFO +24 -11
  9. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyRFC3339.egg-info/SOURCES.txt +3 -3
  10. pyrfc3339-2.1.2/pyRFC3339.egg-info/scm_file_list.json +44 -0
  11. pyrfc3339-2.1.2/pyRFC3339.egg-info/scm_version.json +8 -0
  12. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyproject.toml +29 -31
  13. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyrfc3339/__init__.py +2 -2
  14. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyrfc3339/generator.py +17 -9
  15. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyrfc3339/parser.py +32 -25
  16. pyrfc3339-2.1.0/README.rst +0 -44
  17. pyrfc3339-2.1.0/docs/requirements.txt +0 -3
  18. pyrfc3339-2.1.0/docs/source/utils.rst +0 -6
  19. pyrfc3339-2.1.0/pyrfc3339/utils.py +0 -34
  20. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/.gitignore +0 -0
  21. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/MANIFEST.in +0 -0
  22. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/build/.gitignore +0 -0
  23. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/_static/.gitignore +0 -0
  24. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/_templates/.gitignore +0 -0
  25. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/changes.rst +0 -0
  26. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/generator.rst +0 -0
  27. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/index.rst +0 -0
  28. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/intro.rst +0 -0
  29. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/license.rst +0 -0
  30. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/parser.rst +0 -0
  31. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/docs/source/pyrfc3339.rst +0 -0
  32. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyRFC3339.egg-info/dependency_links.txt +0 -0
  33. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyRFC3339.egg-info/top_level.txt +0 -0
  34. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/pyrfc3339/py.typed +0 -0
  35. {pyrfc3339-2.1.0 → pyrfc3339-2.1.2}/setup.cfg +0 -0
@@ -1,6 +1,25 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 2.1.2 (2026-11-28)
5
+ ------------------
6
+
7
+ - Update ``README`` to clarify that this package does nothing special
8
+ which cannot be done by :mod:`datetime` and :mod:`zoneinfo` and has been
9
+ made irrelevant by improvements to the Python standard library.
10
+ - Simplify logic to eliminate all uses of regular expressions (except in some tests).
11
+ - Simplify logic to eliminate the ``pyrfc3339.utils`` module.
12
+
13
+
14
+ 2.1.1 (2026-10-10)
15
+ ------------------
16
+
17
+ - Drop support for (and cease testing on) Python 3.9 and 3.10.
18
+ Begin testing on Python 3.14 and 3.15.
19
+ Remove a workaround for fractional seconds on Python versions prior to 3.11.
20
+ - Replace ``flake8``, ``isort``, and ``black`` with ``ruff``;
21
+ correct failing ``ruff`` lints and reformat codebase.
22
+
4
23
  2.1.0 (2025-08-23)
5
24
  ------------------
6
25
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2025 Contributors to the pyRFC3339 project
1
+ Copyright (c) 2026 Contributors to the pyRFC3339 project
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyRFC3339
3
- Version: 2.1.0
3
+ Version: 2.1.2
4
4
  Summary: Generate and parse RFC 3339 timestamps
5
5
  Author-email: Kurt Raschke <kurt@kurtraschke.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/kurtraschke/pyrfc3339
8
8
  Project-URL: Documentation, https://pyrfc3339.readthedocs.io/
9
- Project-URL: Repository, https://github.com/kurtraschke/pyRFC3339.git
10
- Project-URL: Bug Tracker, https://github.com/kurtraschke/pyRFC3339/issues
9
+ Project-URL: Source, https://github.com/kurtraschke/pyRFC3339.git
10
+ Project-URL: Issues, https://github.com/kurtraschke/pyRFC3339/issues
11
11
  Project-URL: Changelog, https://github.com/kurtraschke/pyRFC3339/blob/main/CHANGES.rst
12
12
  Keywords: rfc-3339,timestamp,iso-8601,datetime
13
13
  Classifier: Development Status :: 5 - Production/Stable
@@ -15,20 +15,17 @@ Classifier: Intended Audience :: Developers
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
18
  Classifier: Programming Language :: Python :: 3.11
21
19
  Classifier: Programming Language :: Python :: 3.12
22
20
  Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
23
  Classifier: Topic :: Internet
24
- Requires-Python: >=3.9
24
+ Requires-Python: >=3.11
25
25
  Description-Content-Type: text/x-rst
26
26
  License-File: LICENSE.txt
27
27
  Dynamic: license-file
28
28
 
29
- Description
30
- ===========
31
-
32
29
  .. image:: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml/badge.svg
33
30
  :target: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml
34
31
  :alt: Build Status
@@ -37,17 +34,29 @@ Description
37
34
  :target: https://pyrfc3339.readthedocs.io/en/latest/?badge=latest
38
35
  :alt: Documentation Status
39
36
 
37
+ Description
38
+ ===========
39
+
40
40
  pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using `Python <https://www.python.org/>`_ `datetime.datetime <https://docs.python.org/3/library/datetime.html#datetime-objects>`_ objects.
41
41
 
42
42
  >>> from pyrfc3339 import generate, parse
43
- >>> from datetime import datetime, timezone
44
- >>> generate(datetime.now(timezone.utc)) #doctest:+ELLIPSIS
43
+ >>> from datetime import UTC, datetime
44
+ >>> generate(datetime.now(UTC)) #doctest:+ELLIPSIS
45
45
  '...T...Z'
46
46
  >>> parse('2009-01-01T10:01:02Z')
47
47
  datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
48
48
  >>> parse('2009-01-01T14:01:02-04:00')
49
49
  datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000)))
50
50
 
51
+ Status
52
+ ======
53
+
54
+ The first lines of code for what would become pyRFC3339 were written in 2009, as part of a larger project which would itself never see the light of day. At the time, the most expedient approach to parsing RFC 3339 timestamps seemed to be to use a regular expression derived from the ABNF grammar contained in the RFC. In retrospect, this seems absurd. Seventeen years later, the Python standard library is now well-suited to the task.
55
+
56
+ To be blunt: **you do not need pyRFC3339 on any modern version of Python** [#f1]_. This library is now merely a thin wrapper around the `datetime.datetime.fromisoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat>`_ and `datetime.datetime.isoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat>`_. You can call these functions yourself and eliminate a dependency from your dependency tree.
57
+
58
+ It is completely true that once upon a time, handling of `ISO 8601 <https://www.iso.org/iso-8601-date-and-time-format.html>`_ (and, by extension, RFC 3339) timestamps was a notable blindspot in Python's "batteries-included" standard library. But this is no longer the case. There is now built-in support for the `IANA time zone database <https://www.iana.org/time-zones>`_ as well as all of the relevant parts of ISO 8601.
59
+
51
60
  Installation
52
61
  ============
53
62
 
@@ -70,3 +79,7 @@ To build the documentation with Sphinx:
70
79
  The documentation is also available online at:
71
80
 
72
81
  https://pyrfc3339.readthedocs.io/
82
+
83
+ .. rubric:: Footnotes
84
+
85
+ .. [#f1] for clarity, any Python version supported as of November 2026, or any version greater than or equal to 3.11
@@ -0,0 +1,57 @@
1
+ .. image:: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml/badge.svg
2
+ :target: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml
3
+ :alt: Build Status
4
+
5
+ .. image:: https://readthedocs.org/projects/pyrfc3339/badge/?version=latest
6
+ :target: https://pyrfc3339.readthedocs.io/en/latest/?badge=latest
7
+ :alt: Documentation Status
8
+
9
+ Description
10
+ ===========
11
+
12
+ pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using `Python <https://www.python.org/>`_ `datetime.datetime <https://docs.python.org/3/library/datetime.html#datetime-objects>`_ objects.
13
+
14
+ >>> from pyrfc3339 import generate, parse
15
+ >>> from datetime import UTC, datetime
16
+ >>> generate(datetime.now(UTC)) #doctest:+ELLIPSIS
17
+ '...T...Z'
18
+ >>> parse('2009-01-01T10:01:02Z')
19
+ datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
20
+ >>> parse('2009-01-01T14:01:02-04:00')
21
+ datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000)))
22
+
23
+ Status
24
+ ======
25
+
26
+ The first lines of code for what would become pyRFC3339 were written in 2009, as part of a larger project which would itself never see the light of day. At the time, the most expedient approach to parsing RFC 3339 timestamps seemed to be to use a regular expression derived from the ABNF grammar contained in the RFC. In retrospect, this seems absurd. Seventeen years later, the Python standard library is now well-suited to the task.
27
+
28
+ To be blunt: **you do not need pyRFC3339 on any modern version of Python** [#f1]_. This library is now merely a thin wrapper around the `datetime.datetime.fromisoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat>`_ and `datetime.datetime.isoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat>`_. You can call these functions yourself and eliminate a dependency from your dependency tree.
29
+
30
+ It is completely true that once upon a time, handling of `ISO 8601 <https://www.iso.org/iso-8601-date-and-time-format.html>`_ (and, by extension, RFC 3339) timestamps was a notable blindspot in Python's "batteries-included" standard library. But this is no longer the case. There is now built-in support for the `IANA time zone database <https://www.iana.org/time-zones>`_ as well as all of the relevant parts of ISO 8601.
31
+
32
+ Installation
33
+ ============
34
+
35
+ To install the latest version from `PyPI <https://pypi.org/>`_:
36
+
37
+ ``$ pip install pyRFC3339``
38
+
39
+ To install the latest development version:
40
+
41
+ ``$ pip install https://github.com/kurtraschke/pyRFC3339/tarball/main#egg=pyRFC3339-dev``
42
+
43
+ Tests as well as enforcement of code style, formatting, and type safety are run with `tox <https://tox.wiki/>`_:
44
+
45
+ ``$ tox``
46
+
47
+ To build the documentation with Sphinx:
48
+
49
+ ``$ tox -e docs``
50
+
51
+ The documentation is also available online at:
52
+
53
+ https://pyrfc3339.readthedocs.io/
54
+
55
+ .. rubric:: Footnotes
56
+
57
+ .. [#f1] for clarity, any Python version supported as of November 2026, or any version greater than or equal to 3.11
@@ -0,0 +1,3 @@
1
+ Sphinx==9.2.0
2
+ sphinx-issues==6.0.0
3
+ sphinx-rtd-theme==3.1.0
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
1
  # pyRFC3339 documentation build configuration file, created by
4
2
  # sphinx-quickstart on Mon Jul 27 19:32:42 2009.
5
3
  #
@@ -11,197 +9,194 @@
11
9
  # All configuration values have a default; values that are commented out
12
10
  # serve to show the default.
13
11
 
14
- import sys, os
15
12
  from importlib.metadata import version as get_version
16
13
 
17
-
18
14
  # If extensions (or modules to document with autodoc) are in another directory,
19
15
  # add these directories to sys.path here. If the directory is relative to the
20
16
  # documentation root, use os.path.abspath to make it absolute, like shown here.
21
- #sys.path.append(os.path.abspath('.'))
17
+ # sys.path.append(os.path.abspath('.'))
22
18
 
23
19
  # -- General configuration -----------------------------------------------------
24
20
 
25
21
  # Add any Sphinx extension module names here, as strings. They can be extensions
26
22
  # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
27
- extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx_issues']
23
+ extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx_issues"]
28
24
 
29
25
  # Add any paths that contain templates here, relative to this directory.
30
- templates_path = ['_templates']
26
+ templates_path = ["_templates"]
31
27
 
32
28
  # The suffix of source filenames.
33
- source_suffix = {'.rst': 'restructuredtext'}
29
+ source_suffix = {".rst": "restructuredtext"}
34
30
 
35
31
  # The encoding of source files.
36
- #source_encoding = 'utf-8'
32
+ # source_encoding = 'utf-8'
37
33
 
38
34
  # The master toctree document.
39
- master_doc = 'index'
35
+ master_doc = "index"
40
36
 
41
37
  # General information about the project.
42
- project = u'pyRFC3339'
43
- copyright = u'2025 Contributors to the pyRFC3339 project'
38
+ project = "pyRFC3339"
39
+ copyright = "2026 Contributors to the pyRFC3339 project"
44
40
 
45
41
  # The version info for the project you're documenting, acts as replacement for
46
42
  # |version| and |release|, also used in various other places throughout the
47
43
  # built documents.
48
44
  #
49
45
 
50
- release: str = get_version("pyrfc3339")
51
- version: str = ".".join(release.split('.')[:2])
46
+ release = get_version("pyrfc3339")
47
+ version = ".".join(release.split(".")[:2])
52
48
 
53
49
  # The language for content autogenerated by Sphinx. Refer to documentation
54
50
  # for a list of supported languages.
55
- #language = None
51
+ # language = None
56
52
 
57
53
  # There are two options for replacing |today|: either, you set today to some
58
54
  # non-false value, then it is used:
59
- #today = ''
55
+ # today = ''
60
56
  # Else, today_fmt is used as the format for a strftime call.
61
- #today_fmt = '%B %d, %Y'
57
+ # today_fmt = '%B %d, %Y'
62
58
 
63
59
  # List of documents that shouldn't be included in the build.
64
- #unused_docs = []
60
+ # unused_docs = []
65
61
 
66
62
  # List of directories, relative to source directory, that shouldn't be searched
67
63
  # for source files.
68
64
  exclude_trees = []
69
65
 
70
66
  # The reST default role (used for this markup: `text`) to use for all documents.
71
- #default_role = None
67
+ # default_role = None
72
68
 
73
69
  # If true, '()' will be appended to :func: etc. cross-reference text.
74
- #add_function_parentheses = True
70
+ # add_function_parentheses = True
75
71
 
76
72
  # If true, the current module name will be prepended to all description
77
73
  # unit titles (such as .. function::).
78
- #add_module_names = True
74
+ # add_module_names = True
79
75
 
80
76
  # If true, sectionauthor and moduleauthor directives will be shown in the
81
77
  # output. They are ignored by default.
82
- #show_authors = False
78
+ # show_authors = False
83
79
 
84
80
  # The name of the Pygments (syntax highlighting) style to use.
85
- pygments_style = 'sphinx'
81
+ pygments_style = "sphinx"
86
82
 
87
83
  # A list of ignored prefixes for module index sorting.
88
- #modindex_common_prefix = []
84
+ # modindex_common_prefix = []
89
85
 
90
86
 
91
87
  # -- Options for HTML output ---------------------------------------------------
92
88
 
93
89
  # The theme to use for HTML and HTML Help pages. Major themes that come with
94
90
  # Sphinx are currently 'default' and 'sphinxdoc'.
95
- html_theme = 'sphinx_rtd_theme'
91
+ html_theme = "sphinx_rtd_theme"
96
92
 
97
93
  # Theme options are theme-specific and customize the look and feel of a theme
98
94
  # further. For a list of options available for each theme, see the
99
95
  # documentation.
100
- #html_theme_options = {}
96
+ # html_theme_options = {}
101
97
 
102
98
  # Add any paths that contain custom themes here, relative to this directory.
103
- #html_theme_path = []
99
+ # html_theme_path = []
104
100
 
105
101
  # The name for this set of Sphinx documents. If None, it defaults to
106
102
  # "<project> v<release> documentation".
107
- #html_title = None
103
+ # html_title = None
108
104
 
109
105
  # A shorter title for the navigation bar. Default is the same as html_title.
110
- #html_short_title = None
106
+ # html_short_title = None
111
107
 
112
108
  # The name of an image file (relative to this directory) to place at the top
113
109
  # of the sidebar.
114
- #html_logo = None
110
+ # html_logo = None
115
111
 
116
112
  # The name of an image file (within the static path) to use as favicon of the
117
113
  # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
118
114
  # pixels large.
119
- #html_favicon = None
115
+ # html_favicon = None
120
116
 
121
117
  # Add any paths that contain custom static files (such as style sheets) here,
122
118
  # relative to this directory. They are copied after the builtin static files,
123
119
  # so a file named "default.css" will overwrite the builtin "default.css".
124
- html_static_path = ['_static']
120
+ html_static_path = ["_static"]
125
121
 
126
122
  # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
127
123
  # using the given strftime format.
128
- #html_last_updated_fmt = '%b %d, %Y'
124
+ # html_last_updated_fmt = '%b %d, %Y'
129
125
 
130
126
  # If true, SmartyPants will be used to convert quotes and dashes to
131
127
  # typographically correct entities.
132
- #html_use_smartypants = True
128
+ # html_use_smartypants = True
133
129
 
134
130
  # Custom sidebar templates, maps document names to template names.
135
- #html_sidebars = {}
131
+ # html_sidebars = {}
136
132
 
137
133
  # Additional templates that should be rendered to pages, maps page names to
138
134
  # template names.
139
- #html_additional_pages = {}
135
+ # html_additional_pages = {}
140
136
 
141
137
  # If false, no module index is generated.
142
- #html_use_modindex = True
138
+ # html_use_modindex = True
143
139
 
144
140
  # If false, no index is generated.
145
- #html_use_index = True
141
+ # html_use_index = True
146
142
 
147
143
  # If true, the index is split into individual pages for each letter.
148
- #html_split_index = False
144
+ # html_split_index = False
149
145
 
150
146
  # If true, links to the reST sources are added to the pages.
151
- #html_show_sourcelink = True
147
+ # html_show_sourcelink = True
152
148
 
153
149
  # If true, an OpenSearch description file will be output, and all pages will
154
150
  # contain a <link> tag referring to it. The value of this option must be the
155
151
  # base URL from which the finished HTML is served.
156
- #html_use_opensearch = ''
152
+ # html_use_opensearch = ''
157
153
 
158
154
  # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
159
- #html_file_suffix = ''
155
+ # html_file_suffix = ''
160
156
 
161
157
  # Output file base name for HTML help builder.
162
- htmlhelp_basename = 'pyRFC3339doc'
158
+ htmlhelp_basename = "pyRFC3339doc"
163
159
 
164
160
 
165
161
  # -- Options for LaTeX output --------------------------------------------------
166
162
 
167
163
  # The paper size ('letter' or 'a4').
168
- #latex_paper_size = 'letter'
164
+ # latex_paper_size = 'letter'
169
165
 
170
166
  # The font size ('10pt', '11pt' or '12pt').
171
- #latex_font_size = '10pt'
167
+ # latex_font_size = '10pt'
172
168
 
173
169
  # Grouping the document tree into LaTeX files. List of tuples
174
170
  # (source start file, target name, title, author, documentclass [howto/manual]).
175
171
  latex_documents = [
176
- ('index', 'pyRFC3339.tex', u'pyRFC3339 Documentation',
177
- u'Kurt Raschke', 'manual'),
172
+ ("index", "pyRFC3339.tex", "pyRFC3339 Documentation", "Kurt Raschke", "manual"),
178
173
  ]
179
174
 
180
175
  # The name of an image file (relative to this directory) to place at the top of
181
176
  # the title page.
182
- #latex_logo = None
177
+ # latex_logo = None
183
178
 
184
179
  # For "manual" documents, if this is true, then toplevel headings are parts,
185
180
  # not chapters.
186
- #latex_use_parts = False
181
+ # latex_use_parts = False
187
182
 
188
183
  # Additional stuff for the LaTeX preamble.
189
- #latex_preamble = ''
184
+ # latex_preamble = ''
190
185
 
191
186
  # Documents to append as an appendix to all manuals.
192
- #latex_appendices = []
187
+ # latex_appendices = []
193
188
 
194
189
  # If false, no module index is generated.
195
- #latex_use_modindex = True
190
+ # latex_use_modindex = True
196
191
 
197
192
 
198
193
  # Example configuration for intersphinx: refer to the Python standard library.
199
- intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
194
+ intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
200
195
 
201
- issues_github_path = 'kurtraschke/pyrfc3339'
196
+ issues_github_path = "kurtraschke/pyrfc3339"
202
197
 
203
198
  rst_prolog = """
204
199
  .. role:: python(code)
205
200
  :language: python
206
201
  :class: highlight
207
- """
202
+ """
@@ -8,4 +8,3 @@ Modules
8
8
  pyrfc3339
9
9
  generator
10
10
  parser
11
- utils
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyRFC3339
3
- Version: 2.1.0
3
+ Version: 2.1.2
4
4
  Summary: Generate and parse RFC 3339 timestamps
5
5
  Author-email: Kurt Raschke <kurt@kurtraschke.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/kurtraschke/pyrfc3339
8
8
  Project-URL: Documentation, https://pyrfc3339.readthedocs.io/
9
- Project-URL: Repository, https://github.com/kurtraschke/pyRFC3339.git
10
- Project-URL: Bug Tracker, https://github.com/kurtraschke/pyRFC3339/issues
9
+ Project-URL: Source, https://github.com/kurtraschke/pyRFC3339.git
10
+ Project-URL: Issues, https://github.com/kurtraschke/pyRFC3339/issues
11
11
  Project-URL: Changelog, https://github.com/kurtraschke/pyRFC3339/blob/main/CHANGES.rst
12
12
  Keywords: rfc-3339,timestamp,iso-8601,datetime
13
13
  Classifier: Development Status :: 5 - Production/Stable
@@ -15,20 +15,17 @@ Classifier: Intended Audience :: Developers
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
- Classifier: Programming Language :: Python :: 3.9
19
- Classifier: Programming Language :: Python :: 3.10
20
18
  Classifier: Programming Language :: Python :: 3.11
21
19
  Classifier: Programming Language :: Python :: 3.12
22
20
  Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
23
  Classifier: Topic :: Internet
24
- Requires-Python: >=3.9
24
+ Requires-Python: >=3.11
25
25
  Description-Content-Type: text/x-rst
26
26
  License-File: LICENSE.txt
27
27
  Dynamic: license-file
28
28
 
29
- Description
30
- ===========
31
-
32
29
  .. image:: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml/badge.svg
33
30
  :target: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml
34
31
  :alt: Build Status
@@ -37,17 +34,29 @@ Description
37
34
  :target: https://pyrfc3339.readthedocs.io/en/latest/?badge=latest
38
35
  :alt: Documentation Status
39
36
 
37
+ Description
38
+ ===========
39
+
40
40
  pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using `Python <https://www.python.org/>`_ `datetime.datetime <https://docs.python.org/3/library/datetime.html#datetime-objects>`_ objects.
41
41
 
42
42
  >>> from pyrfc3339 import generate, parse
43
- >>> from datetime import datetime, timezone
44
- >>> generate(datetime.now(timezone.utc)) #doctest:+ELLIPSIS
43
+ >>> from datetime import UTC, datetime
44
+ >>> generate(datetime.now(UTC)) #doctest:+ELLIPSIS
45
45
  '...T...Z'
46
46
  >>> parse('2009-01-01T10:01:02Z')
47
47
  datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
48
48
  >>> parse('2009-01-01T14:01:02-04:00')
49
49
  datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000)))
50
50
 
51
+ Status
52
+ ======
53
+
54
+ The first lines of code for what would become pyRFC3339 were written in 2009, as part of a larger project which would itself never see the light of day. At the time, the most expedient approach to parsing RFC 3339 timestamps seemed to be to use a regular expression derived from the ABNF grammar contained in the RFC. In retrospect, this seems absurd. Seventeen years later, the Python standard library is now well-suited to the task.
55
+
56
+ To be blunt: **you do not need pyRFC3339 on any modern version of Python** [#f1]_. This library is now merely a thin wrapper around the `datetime.datetime.fromisoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat>`_ and `datetime.datetime.isoformat() <https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat>`_. You can call these functions yourself and eliminate a dependency from your dependency tree.
57
+
58
+ It is completely true that once upon a time, handling of `ISO 8601 <https://www.iso.org/iso-8601-date-and-time-format.html>`_ (and, by extension, RFC 3339) timestamps was a notable blindspot in Python's "batteries-included" standard library. But this is no longer the case. There is now built-in support for the `IANA time zone database <https://www.iana.org/time-zones>`_ as well as all of the relevant parts of ISO 8601.
59
+
51
60
  Installation
52
61
  ============
53
62
 
@@ -70,3 +79,7 @@ To build the documentation with Sphinx:
70
79
  The documentation is also available online at:
71
80
 
72
81
  https://pyrfc3339.readthedocs.io/
82
+
83
+ .. rubric:: Footnotes
84
+
85
+ .. [#f1] for clarity, any Python version supported as of November 2026, or any version greater than or equal to 3.11
@@ -15,15 +15,15 @@ docs/source/intro.rst
15
15
  docs/source/license.rst
16
16
  docs/source/parser.rst
17
17
  docs/source/pyrfc3339.rst
18
- docs/source/utils.rst
19
18
  docs/source/_static/.gitignore
20
19
  docs/source/_templates/.gitignore
21
20
  pyRFC3339.egg-info/PKG-INFO
22
21
  pyRFC3339.egg-info/SOURCES.txt
23
22
  pyRFC3339.egg-info/dependency_links.txt
23
+ pyRFC3339.egg-info/scm_file_list.json
24
+ pyRFC3339.egg-info/scm_version.json
24
25
  pyRFC3339.egg-info/top_level.txt
25
26
  pyrfc3339/__init__.py
26
27
  pyrfc3339/generator.py
27
28
  pyrfc3339/parser.py
28
- pyrfc3339/py.typed
29
- pyrfc3339/utils.py
29
+ pyrfc3339/py.typed
@@ -0,0 +1,44 @@
1
+ {
2
+ "files": [
3
+ ".github/dependabot.yml",
4
+ ".github/workflows/python.yml",
5
+ ".github/workflows/zizmor.yml",
6
+ ".gitignore",
7
+ ".idea/codeStyles/Project.xml",
8
+ ".idea/codeStyles/codeStyleConfig.xml",
9
+ ".idea/go.imports.xml",
10
+ ".idea/inspectionProfiles/Project_Default.xml",
11
+ ".idea/jsonSchemas.xml",
12
+ ".idea/misc.xml",
13
+ ".idea/modules.xml",
14
+ ".idea/play2_compiler_settings.xml",
15
+ ".idea/pyLspTools.xml",
16
+ ".idea/pyRFC3339.iml",
17
+ ".idea/vcs.xml",
18
+ ".readthedocs.yml",
19
+ "CHANGES.rst",
20
+ "LICENSE.txt",
21
+ "MANIFEST.in",
22
+ "README.rst",
23
+ "docs/build/.gitignore",
24
+ "docs/requirements.txt",
25
+ "docs/source/_static/.gitignore",
26
+ "docs/source/_templates/.gitignore",
27
+ "docs/source/changes.rst",
28
+ "docs/source/conf.py",
29
+ "docs/source/doc.rst",
30
+ "docs/source/generator.rst",
31
+ "docs/source/index.rst",
32
+ "docs/source/intro.rst",
33
+ "docs/source/license.rst",
34
+ "docs/source/parser.rst",
35
+ "docs/source/pyrfc3339.rst",
36
+ "pyproject.toml",
37
+ "pyrfc3339/__init__.py",
38
+ "pyrfc3339/generator.py",
39
+ "pyrfc3339/parser.py",
40
+ "pyrfc3339/py.typed",
41
+ "pyrfc3339/tests/__init__.py",
42
+ "pyrfc3339/tests/test_all.py"
43
+ ]
44
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "2.1.2",
3
+ "distance": 0,
4
+ "node": "ge7cf5668da54dc8bb1b4b015649fee2bca0dec1f",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-28"
8
+ }
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "pyRFC3339"
7
7
  dynamic = ["version"]
8
- requires-python = ">= 3.9"
8
+ requires-python = ">= 3.11"
9
9
  authors = [
10
10
  { name = "Kurt Raschke", email = "kurt@kurtraschke.com" }
11
11
  ]
@@ -20,19 +20,19 @@ classifiers = [
20
20
  "Programming Language :: Python",
21
21
  "Programming Language :: Python :: 3",
22
22
  "Programming Language :: Python :: 3 :: Only",
23
- "Programming Language :: Python :: 3.9",
24
- "Programming Language :: Python :: 3.10",
25
23
  "Programming Language :: Python :: 3.11",
26
24
  "Programming Language :: Python :: 3.12",
27
25
  "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Programming Language :: Python :: 3.15",
28
28
  "Topic :: Internet"
29
29
  ]
30
30
 
31
31
  [project.urls]
32
32
  Homepage = "https://github.com/kurtraschke/pyrfc3339"
33
33
  Documentation = "https://pyrfc3339.readthedocs.io/"
34
- Repository = "https://github.com/kurtraschke/pyRFC3339.git"
35
- "Bug Tracker" = "https://github.com/kurtraschke/pyRFC3339/issues"
34
+ Source = "https://github.com/kurtraschke/pyRFC3339.git"
35
+ Issues = "https://github.com/kurtraschke/pyRFC3339/issues"
36
36
  Changelog = "https://github.com/kurtraschke/pyRFC3339/blob/main/CHANGES.rst"
37
37
 
38
38
  [tool.setuptools]
@@ -40,29 +40,20 @@ packages = ["pyrfc3339"]
40
40
 
41
41
  [tool.setuptools_scm]
42
42
 
43
- [tool.mypy]
44
- strict = true
45
-
46
- [tool.flake8]
47
- max-line-length = 132
48
-
49
- [tool.isort]
50
- profile = "black"
51
-
52
43
  [tool.coverage.run]
53
44
  omit = ["pyrfc3339/tests/*"]
54
45
 
55
46
  [tool.tox]
56
47
  requires = ["tox>=4"]
57
- env_list = ["sort", "format", "style", "type", "3.9", "3.10", "3.11", "3.12", "3.13"]
48
+ env_list = ["coverage-clean", "ruff-lint", "ty", "ruff-format", "3.11", "3.12", "3.13", "3.14", "3.15", "coverage-report"]
58
49
  skip_missing_interpreters = true
59
50
 
60
51
  [tool.tox.gh.python]
61
- "3.13" = ["sort", "format", "style", "type", "3.13"]
52
+ "3.15" = ["ruff-lint", "ty", "ruff-format", "3.15"]
53
+ "3.14" = ["3.14"]
54
+ "3.13" = ["3.13"]
62
55
  "3.12" = ["3.12"]
63
56
  "3.11" = ["3.11"]
64
- "3.10" = ["3.10"]
65
- "3.9" = ["3.9"]
66
57
 
67
58
  [tool.tox.env_run_base]
68
59
  deps = ["pytest", "pytest-subtests", "pytest-cov", "tzdata;platform_system==\"Windows\""]
@@ -72,28 +63,35 @@ commands = [["pytest",
72
63
  "--doctest-modules",
73
64
  "--doctest-continue-on-failure",
74
65
  "--cov=pyrfc3339",
66
+ "--cov-append",
67
+ "--cov-report=",
75
68
  "."]]
76
69
 
77
- [tool.tox.env.type]
70
+ [tool.tox.env.coverage-clean]
71
+ skip_install = true
72
+ deps = ["coverage"]
73
+ commands = [["coverage", "erase"]]
74
+
75
+ [tool.tox.env.coverage-report]
78
76
  skip_install = true
79
- deps = ["mypy"]
80
- commands = [["mypy", "pyrfc3339"]]
77
+ deps = ["coverage"]
78
+ commands = [["coverage", "report", "--show-missing"], ["coverage", "html"]]
81
79
 
82
- [tool.tox.env.sort]
80
+ [tool.tox.env.ty]
83
81
  skip_install = true
84
- deps = ["isort"]
85
- commands = [["isort", "--check", "--diff", "pyrfc3339"]]
82
+ deps = ["ty"]
83
+ commands = [["ty", "check"]]
86
84
 
87
- [tool.tox.env.format]
85
+ [tool.tox.env.ruff-lint]
88
86
  skip_install = true
89
- deps = ["black"]
90
- commands = [["black", "--check", "--diff", "pyrfc3339"]]
87
+ deps = ["ruff"]
88
+ commands = [["ruff", "check"]]
91
89
 
92
- [tool.tox.env.style]
90
+ [tool.tox.env.ruff-format]
93
91
  skip_install = true
94
- deps = ["flake8", "flake8-pyproject"]
95
- commands = [["flake8", "pyrfc3339"]]
92
+ deps = ["ruff"]
93
+ commands = [["ruff", "format", "--check", "--diff"]]
96
94
 
97
95
  [tool.tox.env.docs]
98
96
  deps = ["-r docs/requirements.txt"]
99
- commands = [["sphinx-build", "-M", "html", "docs/source", "docs/build"]]
97
+ commands = [["sphinx-build", "-M", "html", "docs/source", "docs/build"]]
@@ -3,8 +3,8 @@ pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using Python
3
3
  :class:`datetime.datetime` objects.
4
4
 
5
5
  >>> from pyrfc3339 import generate, parse
6
- >>> from datetime import datetime, timezone
7
- >>> generate(datetime.now(timezone.utc)) #doctest:+ELLIPSIS
6
+ >>> from datetime import datetime, UTC
7
+ >>> generate(datetime.now(UTC)) #doctest:+ELLIPSIS
8
8
  '...T...Z'
9
9
  >>> parse('2009-01-01T10:01:02Z')
10
10
  datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
@@ -1,5 +1,4 @@
1
- import re
2
- from datetime import datetime, timezone
1
+ from datetime import UTC, datetime
3
2
 
4
3
 
5
4
  def generate(
@@ -11,21 +10,30 @@ def generate(
11
10
  """
12
11
  Generate an :RFC:`3339`-formatted timestamp from a :class:`datetime.datetime`.
13
12
 
14
- >>> from datetime import datetime, timezone
13
+ >>> from datetime import datetime, UTC
15
14
  >>> from zoneinfo import ZoneInfo
16
- >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0, timezone.utc))
15
+ >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0, UTC))
17
16
  '2009-01-01T12:59:59Z'
18
17
 
19
18
  The timestamp be normalized to UTC unless :python:`utc=False` is specified, in which case
20
19
  it will use the timezone from the :class:`~datetime.datetime`'s :attr:`~datetime.datetime.tzinfo` attribute.
21
20
 
22
21
  >>> eastern = ZoneInfo('US/Eastern')
23
- >>> dt = datetime(2009, 1, 1, 12, 59, 59, tzinfo=eastern)
22
+ >>> dt = datetime(2009, 1, 1, 12, 59, 59, 0, eastern)
24
23
  >>> generate(dt)
25
24
  '2009-01-01T17:59:59Z'
26
25
  >>> generate(dt, utc=False)
27
26
  '2009-01-01T12:59:59-05:00'
28
27
 
28
+ Timestamps which are explicitly in UTC will have their timezone offset set to 'Z', while those which are not UTC
29
+ but happen to be '+00:00' will remain unchanged.
30
+
31
+ >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0, UTC))
32
+ '2009-01-01T12:59:59Z'
33
+ >>> london = ZoneInfo('Europe/London')
34
+ >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0, london), utc=False)
35
+ '2009-01-01T12:59:59+00:00'
36
+
29
37
  Unless :python:`accept_naive=True` is specified, the :class:`~datetime.datetime` must not be naive.
30
38
 
31
39
  >>> generate(datetime(2009, 1, 1, 12, 59, 59, 0))
@@ -62,7 +70,7 @@ def generate(
62
70
  if dt.tzinfo is None:
63
71
  if accept_naive:
64
72
  if utc:
65
- dt = dt.replace(tzinfo=timezone.utc)
73
+ dt = dt.replace(tzinfo=UTC)
66
74
  else:
67
75
  raise ValueError(
68
76
  "cannot generate a local timestamp from a naive datetime"
@@ -71,11 +79,11 @@ def generate(
71
79
  raise ValueError("naive datetime and accept_naive is False")
72
80
 
73
81
  if utc:
74
- dt = dt.astimezone(timezone.utc)
82
+ dt = dt.astimezone(UTC)
75
83
 
76
84
  timestamp = dt.isoformat(timespec="microseconds" if microseconds else "seconds")
77
85
 
78
- if dt.tzinfo == timezone.utc:
79
- timestamp = re.sub(r"\+00:00$", "Z", timestamp)
86
+ if dt.tzinfo == UTC and timestamp.endswith("+00:00"):
87
+ timestamp = timestamp[:-6] + "Z"
80
88
 
81
89
  return timestamp
@@ -1,8 +1,4 @@
1
- import re
2
- import sys
3
- from datetime import datetime, timezone
4
-
5
- from .utils import datetime_utcoffset
1
+ from datetime import UTC, datetime
6
2
 
7
3
 
8
4
  def parse(timestamp: str, utc: bool = False, produce_naive: bool = False) -> datetime:
@@ -28,6 +24,29 @@ def parse(timestamp: str, utc: bool = False, produce_naive: bool = False) -> dat
28
24
  >>> parse('2009-01-01T06:01:02-04:00', utc=True)
29
25
  datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
30
26
 
27
+ If :meth:`parse()` is called with :python:`produce_naive=True`, then the returned
28
+ :class:`~datetime.datetime` will be naive (and its :attr:`~datetime.datetime.tzinfo` attribute set to
29
+ :python:`None`). This is not permitted for input timestamps which have a non-zero timezone offset, unless those
30
+ are normalized to UTC with the use of :python:`utc=True`.
31
+ The use of naive datetimes, is, as a matter of course, not recommended.
32
+
33
+ >>> parse('2009-01-01T06:01:02Z', produce_naive=True)
34
+ datetime.datetime(2009, 1, 1, 6, 1, 2)
35
+
36
+ >>> parse('2009-01-01T06:01:02+00:00', produce_naive=True)
37
+ datetime.datetime(2009, 1, 1, 6, 1, 2)
38
+
39
+ >>> parse('2009-01-01T06:01:02-00:00', produce_naive=True)
40
+ datetime.datetime(2009, 1, 1, 6, 1, 2)
41
+
42
+ >>> parse('2009-01-01T06:01:02-04:00', produce_naive=True)
43
+ Traceback (most recent call last):
44
+ ...
45
+ ValueError: cannot produce a naive datetime from a local timestamp
46
+
47
+ >>> parse('2009-01-01T06:01:02-04:00', utc=True, produce_naive=True)
48
+ datetime.datetime(2009, 1, 1, 10, 1, 2)
49
+
31
50
  As parsing is delegated to :meth:`datetime.datetime.fromisoformat()`, certain
32
51
  timestamps which do not strictly adhere to :RFC:`3339` are nonetheless accepted.
33
52
 
@@ -36,7 +55,7 @@ def parse(timestamp: str, utc: bool = False, produce_naive: bool = False) -> dat
36
55
 
37
56
  Exceptions will, however, be thrown for blatantly invalid input:
38
57
 
39
- >>> parse('2009-01-01T25:01:02Z')
58
+ >>> parse('2009-01-01T25:01:02Z') # doctest: +IGNORE_EXCEPTION_DETAIL
40
59
  Traceback (most recent call last):
41
60
  ...
42
61
  ValueError: hour must be in 0..23
@@ -45,36 +64,24 @@ def parse(timestamp: str, utc: bool = False, produce_naive: bool = False) -> dat
45
64
  :param bool utc: :const:`True` to normalize the timestamp to UTC; :const:`False` otherwise. Defaults to :const:`False`.
46
65
  :param bool produce_naive: :const:`True` if the produced :class:`~datetime.datetime` instance should
47
66
  not have a timezone attached (that is, be 'naive'); :const:`False` otherwise.
48
- Defaults to :const:`False`.
67
+ Defaults to :const:`False`. Not permitted for input timestamps which have
68
+ a non-zero timezone offset.
49
69
  :return: the parsed timestamp
50
70
  :rtype: datetime.datetime
51
71
 
52
72
  """
53
73
 
54
- # Python does not recognize "Z" as an alias for "+00:00", so we perform the
55
- # substitution here.
56
- timestamp = re.sub("Z$", "+00:00", timestamp, flags=re.IGNORECASE)
57
-
58
- # Python releases prior to 3.11 only support three or six digits of fractional
59
- # seconds. RFC 3339 is more lenient, so pad to six digits and truncate any
60
- # excessive digits.
61
- # This can be removed in October 2026, once Python 3.10 and earlier
62
- # have been retired.
63
- # noinspection PyUnreachableCode
64
- if sys.version_info < (3, 11):
65
- timestamp = re.sub(
66
- r"(\.)([0-9]+)(?=[+\-][0-9]{2}:[0-9]{2}$)",
67
- lambda match: match.group(1) + match.group(2).ljust(6, "0")[:6],
68
- timestamp,
69
- )
74
+ # Python only recognizes the 'Z' suffix, not 'z'. (python/cpython#80010)
75
+ if timestamp.endswith("z"):
76
+ timestamp = timestamp[:-1] + "Z"
70
77
 
71
78
  dt_out = datetime.fromisoformat(timestamp)
72
79
 
73
80
  if utc:
74
- dt_out = dt_out.astimezone(timezone.utc)
81
+ dt_out = dt_out.astimezone(UTC)
75
82
 
76
83
  if produce_naive:
77
- if datetime_utcoffset(dt_out) == 0:
84
+ if dt_out.tzinfo == UTC:
78
85
  dt_out = dt_out.replace(tzinfo=None)
79
86
  else:
80
87
  raise ValueError("cannot produce a naive datetime from a local timestamp")
@@ -1,44 +0,0 @@
1
- Description
2
- ===========
3
-
4
- .. image:: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml/badge.svg
5
- :target: https://github.com/kurtraschke/pyRFC3339/actions/workflows/python.yml
6
- :alt: Build Status
7
-
8
- .. image:: https://readthedocs.org/projects/pyrfc3339/badge/?version=latest
9
- :target: https://pyrfc3339.readthedocs.io/en/latest/?badge=latest
10
- :alt: Documentation Status
11
-
12
- pyRFC3339 parses and generates :RFC:`3339`-compliant timestamps using `Python <https://www.python.org/>`_ `datetime.datetime <https://docs.python.org/3/library/datetime.html#datetime-objects>`_ objects.
13
-
14
- >>> from pyrfc3339 import generate, parse
15
- >>> from datetime import datetime, timezone
16
- >>> generate(datetime.now(timezone.utc)) #doctest:+ELLIPSIS
17
- '...T...Z'
18
- >>> parse('2009-01-01T10:01:02Z')
19
- datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=datetime.timezone.utc)
20
- >>> parse('2009-01-01T14:01:02-04:00')
21
- datetime.datetime(2009, 1, 1, 14, 1, 2, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=72000)))
22
-
23
- Installation
24
- ============
25
-
26
- To install the latest version from `PyPI <https://pypi.org/>`_:
27
-
28
- ``$ pip install pyRFC3339``
29
-
30
- To install the latest development version:
31
-
32
- ``$ pip install https://github.com/kurtraschke/pyRFC3339/tarball/main#egg=pyRFC3339-dev``
33
-
34
- Tests as well as enforcement of code style, formatting, and type safety are run with `tox <https://tox.wiki/>`_:
35
-
36
- ``$ tox``
37
-
38
- To build the documentation with Sphinx:
39
-
40
- ``$ tox -e docs``
41
-
42
- The documentation is also available online at:
43
-
44
- https://pyrfc3339.readthedocs.io/
@@ -1,3 +0,0 @@
1
- Sphinx==8.2.3
2
- sphinx-issues==5.0.1
3
- sphinx-rtd-theme==3.0.2
@@ -1,6 +0,0 @@
1
- :mod:`pyrfc3339.utils` -- Utilities for working with timestamps
2
- ===============================================================
3
-
4
- .. automodule:: pyrfc3339.utils
5
- :members:
6
-
@@ -1,34 +0,0 @@
1
- from datetime import datetime
2
-
3
-
4
- def datetime_utcoffset(dt: datetime) -> float:
5
- """
6
- Return the UTC offset for an aware :class:`datetime.datetime` in seconds.
7
-
8
- >>> from datetime import datetime
9
- >>> from zoneinfo import ZoneInfo
10
- >>> z = ZoneInfo('US/Eastern')
11
- >>> dt = datetime(2024, 11, 5, 19, 7, 6, tzinfo=z)
12
- >>> datetime_utcoffset(dt)
13
- -18000.0
14
-
15
- >>> dt = datetime(2024, 11, 5, 19, 7, 6)
16
- >>> datetime_utcoffset(dt)
17
- Traceback (most recent call last):
18
- ...
19
- AssertionError
20
-
21
- :param datetime.datetime dt: a :class:`~datetime.datetime` instance; must be aware (that is, have a timezone attached)
22
- :return: the UTC offset of the supplied :class:`~datetime.datetime` in seconds
23
- :rtype: float
24
-
25
- """
26
-
27
- assert dt.tzinfo is not None
28
-
29
- tz = dt.tzinfo
30
- offset = tz.utcoffset(dt)
31
-
32
- assert offset is not None
33
-
34
- return offset.total_seconds()
File without changes
File without changes
File without changes
File without changes