Temporal Formatting¶
Date and time formatting utilities.
Formatting Module¶
Date/time formatting utilities.
This submodule provides utilities for formatting datetime objects into various string representations.
Examples¶
from rite.temporal.formatting import format_iso8601 from datetime import datetime, timezone dt = datetime.now(timezone.utc) format_iso8601(dt)
Modules¶
format_human_readable
¶
Format Human Readable¶
Format datetime to human-readable string.
Examples¶
from rite.temporal.formatting import format_human_readable from datetime import datetime format_human_readable(datetime(2024, 12, 27, 15, 30))
Functions¶
format_human_readable(dt: datetime) -> str
¶
Format datetime to human-readable string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime
|
Datetime object. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Human-readable formatted string. |
Examples:
>>> from datetime import datetime
>>> dt = datetime(2024, 12, 27, 15, 30)
>>> format_human_readable(dt)
'December 27, 2024 at 3:30 PM'
Notes
Uses strftime with full month name. 12-hour format with AM/PM.
format_iso8601
¶
Format ISO 8601¶
Format datetime to ISO 8601 string.
Examples¶
from rite.temporal.formatting import format_iso8601 from datetime import datetime, timezone format_iso8601(datetime(2024, 12, 27, tzinfo=timezone.utc))
Functions¶
format_iso8601(dt: datetime) -> str
¶
Format datetime to ISO 8601 string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime
|
Datetime object. |
required |
Returns:
| Type | Description |
|---|---|
str
|
ISO 8601 formatted string. |
Examples:
>>> from datetime import datetime, timezone
>>> dt = datetime(2024, 12, 27, 15, 30, tzinfo=timezone.utc)
>>> format_iso8601(dt)
'2024-12-27T15:30:00+00:00'
Notes
Same as datetime.isoformat().
format_rfc3339
¶
Format RFC 3339¶
Format datetime to RFC 3339 string.
Examples¶
from rite.temporal.formatting import format_rfc3339 from datetime import datetime, timezone format_rfc3339(datetime(2024, 12, 27, tzinfo=timezone.utc))
Functions¶
format_rfc3339(dt: datetime) -> str
¶
Format datetime to RFC 3339 string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime
|
Datetime object. |
required |
Returns:
| Type | Description |
|---|---|
str
|
RFC 3339 formatted string. |
Examples:
>>> from datetime import datetime, timezone
>>> dt = datetime(2024, 12, 27, 15, 30, tzinfo=timezone.utc)
>>> format_rfc3339(dt)
'2024-12-27T15:30:00+00:00'
Notes
RFC 3339 is profile of ISO 8601. Uses isoformat() with 'T' separator.
options: show_root_heading: true show_source: false heading_level: 2