Registry / serialization / strict-rfc3339

strict-rfc3339

JSON →
library0.7pypypi✓ verified 22d ago

strict-rfc3339 is a Python library providing strict, simple, and lightweight functions for converting Unix timestamps to and from RFC3339 formatted strings. It aims to avoid the complexities of timezones as much as possible, focusing on strict adherence to the RFC3339 standard. The current version is 0.7, with development appearing to be in maintenance mode, as the last release was in April 2016.

pip install strict-rfc3339
INSTALL
IMPORT
SIG · STRICT-RFC3339
S
strict-rfc3339
serializationpythonv0.7
Install
2.3s 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.7 · 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.3s · import 0.010s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

validate_rfc3339
from strict_rfc3339 import validate_rfc3339
import strict_rfc3339
now_to_rfc3339_utcoffset
from strict_rfc3339 import now_to_rfc3339_utcoffset
import strict_rfc3339
rfc3339_to_timestamp
from strict_rfc3339 import rfc3339_to_timestamp
import strict_rfc3339

This quickstart demonstrates how to obtain the current time in RFC3339 format (UTC or local offset), validate an RFC3339 string, and convert between RFC3339 strings and Unix timestamps. It highlights the library's core functionalities for strict RFC3339 handling.

import strict_rfc3339 import time # Get current UTC time as RFC3339 string rfc3339_now_utc = strict_rfc3339.now_to_rfc3339_utc() print(f"Current UTC RFC3339: {rfc3339_now_utc}") # Get current local time as RFC3339 string with local offset rfc3339_now_local = strict_rfc3339.now_to_rfc3339_localoffset() print(f"Current Local RFC3339: {rfc3339_now_local}") # Validate an RFC3339 string is_valid = strict_rfc3339.validate_rfc3339("2023-10-27T10:00:00Z") print(f"'2023-10-27T10:00:00Z' is valid: {is_valid}") is_invalid = strict_rfc3339.validate_rfc3339("some rubbish") print(f"'some rubbish' is valid: {is_invalid}") # Convert RFC3339 to Unix timestamp timestamp = strict_rfc3339.rfc3339_to_timestamp("2023-10-27T10:00:00+00:00") print(f"Timestamp for '2023-10-27T10:00:00+00:00': {timestamp}") print(f"Time tuple (UTC): {time.gmtime(timestamp)[:6]}") # Convert Unix timestamp to RFC3339 (UTC) new_rfc3339_utc = strict_rfc3339.timestamp_to_rfc3339_utc(timestamp) print(f"Timestamp {timestamp} to RFC3339 UTC: {new_rfc3339_utc}")
Debug
Known issues
gotchaThe library does not support leap seconds. In validation, seconds values of '60' or '61' are rejected, as Python's native timestamps do not support them, and validating them accurately would require constantly updated timezone data.
fix
Be aware of this limitation; if leap second precision is critical, this library may not be suitable without external handling of leap seconds.
affects: 0.1 - 0.7
gotchaOn 32-bit systems, RFC3339 generation using `gmtime` or `localtime` may be limited by the size of `time_t`, typically restricting dates to between approximately 1901 and 2038. This limitation does not affect `rfc3339_to_timestamp`.
fix
Consider this limitation when deploying on 32-bit systems or working with dates outside this range. For such cases, consider alternative libraries or custom handling.
affects: 0.1 - 0.7
gotchaThe library explicitly avoids direct usage of Python's `datetime` objects and comprehensive timezone libraries like `pytz` to prevent common issues related to DST transitions and ambiguous times. This means that while it strictly handles RFC3339 offsets, it does not provide full timezone conversion capabilities itself.
fix
Understand that the library focuses purely on RFC3339 string parsing and generation based on Unix timestamps, not complex timezone arithmetic. If full timezone support beyond RFC3339 offsets is needed, integrate with a dedicated timezone library, ensuring careful handling of conversions.
affects: 0.1 - 0.7
Upgrade
Version history
0.7latest on PyPI · released Apr 24, 2016
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
strict-rfc3339 — pip install strict-rfc3339 · libregistry