Skip to main content

TagDateTime

No overview available.

Attributes

AttributeTypeDescription
keystr = " 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

NameTypeDescription
valuet.AnyThe value to check for datetime type.

Returns

TypeDescription
boolTrue 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

NameTypeDescription
valuet.AnyThe datetime object to convert to an HTTP date string.

Returns

TypeDescription
t.AnyThe 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

NameTypeDescription
valuet.AnyThe date string to parse into a datetime object.

Returns

TypeDescription
t.AnyA datetime object parsed from the input date string.