Typing Stubs for pyRFC3339

2.0.1.20250825 · active · verified Thu Apr 16

types-pyrfc3339 provides high-quality static type annotations (typing stubs) for the pyRFC3339 library. pyRFC3339 itself is a Python library that parses and generates RFC 3339-compliant timestamps using Python's `datetime.datetime` objects. This stub package, currently at version 2.0.1.20250825, is automatically generated and released from the community-driven Typeshed repository, typically with daily updates to keep pace with changes in the runtime library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of the `pyrfc3339` library for generating and parsing RFC 3339 timestamps. With `types-pyrfc3339` installed, a static type checker can verify the correctness of the types used in these operations, catching potential errors before runtime.

import datetime
from pyrfc3339 import generate, parse

# Get current UTC time to generate an RFC 3339 timestamp
now_utc = datetime.datetime.now(datetime.timezone.utc)
print(f"Current UTC datetime: {now_utc.isoformat()}")

# Generate RFC 3339 timestamp string
rfc3339_string = generate(now_utc)
print(f"Generated RFC 3339 string: {rfc3339_string}")

# Parse an RFC 3339 timestamp string back to a datetime object
some_rfc3339_string = "2023-10-27T10:30:00.123456Z"
parsed_dt = parse(some_rfc3339_string)
print(f"Parsed RFC 3339 string: {parsed_dt}")

# The presence of types-pyrfc3339 allows type checkers (e.g., Mypy) to validate arguments:
# For example, uncommenting the line below would trigger a type error:
# generate("not a datetime object")

view raw JSON →