Registry / serialization / tonyg-rfc3339

tonyg-rfc3339

JSON →
library0.1pypypi✓ verified 25d ago

The `tonyg-rfc3339` library provides a Python implementation for parsing and formatting dates and times according to RFC 3339. It includes `tzinfo` classes for UTC and fixed-offset timezones, aiming for simple, standard, and robust timestamp handling across languages. The current version is 0.1, with its last PyPI release in 2015, suggesting a maintenance or stable status rather than active development.

pip install tonyg-rfc3339
INSTALL
IMPORT
SIG · TONYG-RFC3339
T
tonyg-rfc3339
serializationpythonv0.1
Install
2.4s avg
Import
10ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.010s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse_datetime
from rfc3339 import parse_datetime
generate_datetime
from rfc3339 import generate_datetime
UTC
from rfc3339 import UTC
from rfc3339 import Utc
The `UTC` constant for the timezone object is capitalized.

The quickstart demonstrates parsing RFC 3339 formatted strings into timezone-aware `datetime` objects and generating RFC 3339 strings from `datetime` objects. It also shows how to use the provided `UTC` timezone object and the library's ability to handle timezone offsets for comparison.

from datetime import datetime, timedelta from rfc3339 import parse_datetime, generate_datetime, UTC # Example 1: Parsing an RFC 3339 timestamp timestamp_str = "2023-10-27T10:00:00Z" dt_object = parse_datetime(timestamp_str) print(f"Parsed datetime: {dt_object}") # Expected: Parsed datetime: 2023-10-27 10:00:00+00:00 # Example 2: Parsing with an offset offset_timestamp_str = "2023-10-27T12:00:00+02:00" dt_offset_object = parse_datetime(offset_timestamp_str) print(f"Parsed datetime with offset: {dt_offset_object}") # Expected: Parsed datetime with offset: 2023-10-27 12:00:00+02:00 # Example 3: Generating an RFC 3339 timestamp from a datetime object now_utc = datetime.now(UTC) rfc3339_output = generate_datetime(now_utc) print(f"Generated RFC 3339: {rfc3339_output}") # Expected: Generated RFC 3339: 2026-04-11T18:42:00Z (example time) # Example 4: Comparing two equivalent timestamps (parsed from different zones) midnight_utc = parse_datetime("2008-08-24T00:00:00Z") one_am_bst = parse_datetime("2008-08-24T01:00:00+01:00") print(f"Are equivalent datetimes equal? {midnight_utc == one_am_bst}") # Expected: True
Debug
Known issues
gotchaThe library explicitly states it 'sticks quite closely to the RFC 3339 profile of ISO 8601'. If you require parsing more general or less strict ISO 8601 formats, this library might not be suitable, and you may need alternatives like `pyiso8601`.
fix
For broader ISO 8601 parsing, consider `pyiso8601` or `dateutil`. For simple RFC 3339, ensure input strictly adheres to the standard as defined in the library.
affects: 0.1
gotchaThe library does not implement 'Unknown Local Offset Convention' (RFC 3339 Section 4.3) and only supports 'Internet Date/Time Format' (Section 5.6) for parsing. Leap seconds are also not addressed.
fix
Be aware of these limitations. If your use case involves these specific RFC 3339 nuances (e.g., handling leap seconds or unknown local offsets), this library will not provide the necessary functionality.
affects: 0.1
deprecatedFor Python 3.2 and later, the built-in `datetime` module's `isoformat()` method can generate RFC 3339 compatible strings, and `datetime.fromisoformat()` (Python 3.7+) offers robust ISO 8601 parsing. More modern and actively maintained libraries like `rfc3339lib` or `strict-rfc3339` also exist.
fix
Evaluate if built-in `datetime` functionality (especially `isoformat()` and `fromisoformat()` in Python 3.7+) or other community libraries (e.g., `rfc3339lib`, `strict-rfc3339`) meet your needs more effectively, especially for newer Python versions or if active maintenance is a concern.
affects: All versions (due to evolving Python stdlib)
gotchaThe GitHub repository notes that the project has 'MOVED TO: https://git.leastfixedpoint.com/tonyg/python-rfc3339'. This indicates the GitHub mirror may not be the primary development location, and active development or issue tracking might occur elsewhere, or not at all.
fix
Be aware that the library is not actively maintained on GitHub. For issues or contributions, consulting the 'moved to' URL might be necessary, though given its age, significant updates are unlikely.
affects: 0.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rfc3339'
The `tonyg-rfc3339` package or its `rfc3339` module is not installed in the current Python environment.
fix
Install the package using pip: `pip install tonyg-rfc3339`
ModuleNotFoundError: No module named 'tonyg_rfc3339'
The package name on PyPI (`tonyg-rfc3339`) differs from the actual top-level module name to be imported (`rfc3339`).
fix
Use `import rfc3339` instead of trying to import a module named after the package.
ValueError: Invalid RFC3339 string:
The input string provided to `rfc3339.parse_datetime()` does not conform to the RFC 3339 specification.
fix
Ensure the date-time string strictly follows the RFC 3339 format, for example, "2023-10-27T10:00:00Z" or "2023-10-27T10:00:00-07:00".
AttributeError: 'str' object has no attribute 'utctimetuple'
The `rfc3339.format_datetime()` function expects a `datetime.datetime` object as its first argument, but received an object of a different type (e.g., a string).
fix
Pass a valid `datetime.datetime` object to `rfc3339.format_datetime()`. Example: `rfc3339.format_datetime(datetime.datetime.now())`.
Upgrade
Version history
0.1latest on PyPI · released Dec 5, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
tonyg-rfc3339 — pip install tonyg-rfc3339 · libregistry