Utilities¶
Floating point numbers¶
Module for handling floating point numbers in ATProtocol records.
ATProtocol doesn't support floating point numbers directly, so this module provides functions to convert floats to specially formatted strings and back again.
decode_floats_in_event(event)
¶
Recursively decode all specially marked strings in an event back to floating point numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[str, Any]
|
The event dictionary to process. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A new dictionary with all encoded strings converted back to floating point numbers. |
Source code in nebra/floats.py
encode_floats_in_event(event)
¶
Recursively encode all floating point numbers in an event as specially marked strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict[str, Any]
|
The event dictionary to process. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A new dictionary with all floating point numbers encoded as strings. |
Source code in nebra/floats.py
Time¶
These helpers can create fully AT Protocol-compliant timestamps.
get_atproto_utc_time()
¶
Get a maximally ATProto-compatible UTC datetime string.
This function returns a datetime string in the format specified by the ATProtocol lexicon, which is "YYYY-MM-DDTHH:MM:SS.sssZ".
Returns:
| Type | Description |
|---|---|
str
|
A datetime string in ATProtocol-compatible format. |
See Also
https://atproto.com/specs/lexicon#datetime : ATProtocol datetime specification