Skip to main content

DateTimeBaseInput

This class serves as a base for input widgets that handle date and time values, extending the standard text input functionality. It provides mechanisms for localizing input values based on specific format keys and supports optional microsecond precision. Users can initialize the class with custom attributes and formats to control how date-time data is rendered in forms.

Attributes

AttributeTypeDescription
format_keystring = ""The localization setting key used to retrieve the default date or time formatting string when no specific format is provided.
supports_microsecondsboolean = falseA boolean flag indicating whether the input widget should preserve and display microsecond precision for datetime values.

Constructor

Signature

def DateTimeBaseInput(
attrs: dict = None,
format: str = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneOptional dictionary of HTML attributes to be added to the rendered widget.
formatstr = NoneThe format in which the datetime value should be displayed and parsed.

Signature

def DateTimeBaseInput(
attrs: dict = None,
format: string = None
) - > null

Parameters

NameTypeDescription
attrsdict = NoneA dictionary containing HTML attributes to be rendered on the input element.
formatstring = NoneThe specific date/time format string used to render the value in the field.

Methods


format_value()

@classmethod
def format_value(
value: any
) - > string

Converts the internal Python date/time object into a localized string representation suitable for display in an HTML input field.

Parameters

NameTypeDescription
valueanyThe date, time, or datetime object to be formatted for the input field.

Returns

TypeDescription
stringA localized string representation of the date/time value formatted according to the widget's configuration.