TagDateTime
No overview available.
Attributes
| Attribute | Type | Description |
|---|---|---|
| key | str = " d" | This attribute stores the string identifier ' d' which is used to represent a datetime object when converting to and from JSON. |
Methods
check()
@classmethod
def check(
value: t.Any
) - > bool
Checks if the provided value is a datetime object. This method is used to validate if a given input can be treated as a date and time.
Parameters
| Name | Type | Description |
|---|---|---|
| value | t.Any | The value to check for datetime type. |
Returns
| Type | Description |
|---|---|
bool | True if the value is a datetime object, False otherwise. |
to_json()
@classmethod
def to_json(
value: t.Any
) - > t.Any
Converts a datetime object into an HTTP date string format. This is useful for serializing datetime objects into a standard string representation for JSON output.
Parameters
| Name | Type | Description |
|---|---|---|
| value | t.Any | The datetime object to convert to an HTTP date string. |
Returns
| Type | Description |
|---|---|
t.Any | The datetime object formatted as an HTTP date string. |
to_python()
@classmethod
def to_python(
value: t.Any
) - > t.Any
Parses a date string into a Python datetime object. This method is used to deserialize date strings from JSON input back into native Python datetime objects.
Parameters
| Name | Type | Description |
|---|---|---|
| value | t.Any | The date string to parse into a datetime object. |
Returns
| Type | Description |
|---|---|
t.Any | A datetime object parsed from the input date string. |