widgets.datewidget - Date Widget¶
A datewidget with customizable date format.
-
waeup.kofa.widgets.datewidget.
DATE_FORMATS
= {'iso-year': ('datepicker-year', '%Y-%m-%d'), 'de-year': ('datepicker-de-year', '%d.%m.%Y'), 'le': ('datepicker-le', '%d/%m/%Y'), 'iso': ('datepicker', '%Y-%m-%d'), 'le-year': ('datepicker-le-year', '%d/%m/%Y'), 'de': ('datepicker-de', '%d.%m.%Y'), 'us-year': ('datepicker-us-year', '%m/%d/%Y'), 'us': ('datepicker-us', '%m/%d/%Y')}¶ A dictionary of supported date formats.
The following formats are supported:
iso
- ISO format
YYYY-MM-DD
le
- little endian with slashes:
DD/MM/YYYY
de
- german date format:
DD.MM.YYYY
us
- middle endian format common in the U.S.:
MM/DD/YYYY
Furthermore we support for input widgets an additional year marker. Input date widgets with this marker provide also a year selector, handy for dates of birth etc.
The year-supporting formats are similar to the basic versions above:
iso-year
- ISO format
YYYY-MM-DD
le-year
- little endian with slashes:
DD/MM/YYYY
de-year
- german date format:
DD.MM.YYYY
us-year
- middle endian format common in the U.S.:
MM/DD/YYYY
For date display widgets there is naturally no difference between a year and non-year setting (you can for instance use ‘le’ or ‘le-year’ with the same output).
-
class
waeup.kofa.widgets.datewidget.
DateDEDisplayWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateDisplayWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%d.%m.%Y'¶
-
-
class
waeup.kofa.widgets.datewidget.
DateDEWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%d.%m.%Y'¶
-
-
class
waeup.kofa.widgets.datewidget.
DateLEDisplayWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateDisplayWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%d/%m/%Y'¶
-
-
class
waeup.kofa.widgets.datewidget.
DateLEWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%d/%m/%Y'¶
-
-
class
waeup.kofa.widgets.datewidget.
DateUSDisplayWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateDisplayWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%m/%d/%Y'¶
-
-
class
waeup.kofa.widgets.datewidget.
DateUSWidget
(context, request, *args, **kw)[source]¶ Bases:
waeup.kofa.widgets.datewidget.FormattedDateWidget
-
__doc__
= None¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%m/%d/%Y'¶
-
-
waeup.kofa.widgets.datewidget.
FORMATS_BY_VALUE
= {('%d/%m/%Y', False): 'datepicker-le', ('%d/%m/%Y', True): 'datepicker-le-year', ('%Y-%m-%d', False): 'datepicker', ('%Y-%m-%d', True): 'datepicker-year', ('%d.%m.%Y', False): 'datepicker-de', ('%d.%m.%Y', True): 'datepicker-de-year', ('%m/%d/%Y', False): 'datepicker-us', ('%m/%d/%Y', True): 'datepicker-us-year'}¶ a dict containing tuples (<FORMAT>, <SHOW_YEAR>) as keys and suitable CSS tags as values.
-
class
waeup.kofa.widgets.datewidget.
FormattedDateDisplayWidget
(context, request, *args, **kw)[source]¶ Bases:
zope.formlib.textwidgets.DateDisplayWidget
A date widget that supports different (and _explicit_) date formats.
This is a display widget.
It can also be used for displaying datetimes. If used to display a datetime (not a date), the widget returns local datetime with timezone set according to KofaUtils.
-
__doc__
= 'A date widget that supports different (and _explicit_) date formats.\n\n This is a display widget.\n\n It can also be used for displaying datetimes. If used to display a\n datetime (not a date), the widget returns local datetime with\n timezone set according to KofaUtils.\n '¶
-
__implemented__
= <implementedBy waeup.kofa.widgets.datewidget.FormattedDateDisplayWidget>¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
__provides__
¶ Special descriptor for class __provides__
The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.
For example:
>>> from zope.interface import Interface >>> class IFooFactory(Interface): ... pass >>> class IFoo(Interface): ... pass >>> class C(object): ... implements(IFoo) ... classProvides(IFooFactory) >>> [i.getName() for i in C.__provides__] ['IFooFactory']
>>> [i.getName() for i in C().__provides__] ['IFoo']
-
date_format
= '%Y-%m-%d'¶
-
show_year
= False¶
-
-
class
waeup.kofa.widgets.datewidget.
FormattedDateWidget
(context, request, *args, **kw)[source]¶ Bases:
zope.formlib.textwidgets.DateWidget
A date widget that supports different (and _explicit_) date formats.
If the widget is bound to a schema field with respective attributes, it reads its show_year and date_format attributes (see waeup.kofa.schema.FormattedDate for an example) and sets a CSS tag according to these values.
The widget also accepts ISO format as a fallback, even if a different format was set. This should help with imports.
This is an input widget.
-
__doc__
= 'A date widget that supports different (and _explicit_) date formats.\n\n If the widget is bound to a schema field with respective\n attributes, it reads its `show_year` and `date_format` attributes\n (see waeup.kofa.schema.FormattedDate for an example) and sets a\n CSS tag according to these values.\n\n The widget also accepts ISO format as a fallback, even if a\n different format was set. This should help with imports.\n\n This is an input widget.\n '¶
-
__module__
= 'waeup.kofa.widgets.datewidget'¶
-
date_format
= '%Y-%m-%d'¶
-
show_year
= False¶
-
-
waeup.kofa.widgets.datewidget.
FriendlyDateDisplayWidget
(format)[source]¶ Get a friendly date display widget for format.
This widget is suitable for display forms.
Valid format values are the keys of DATE_FORMATS dict. Default is
le
(little endian; DD/MM/YYYY).This widget is not rendered with a specialized CSS tag for enabling JavaScript datepickers. css_class is ignored which means there is nor difference between e.g.
le
andle-year
.`
-
waeup.kofa.widgets.datewidget.
FriendlyDateWidget
(format)[source]¶ Get a friendly date input widget for format.
This widget is suitable for edit and add forms.
Valid format values are the keys of DATE_FORMATS dict. Default is
le
(little endian; DD/MM/YYYY).Friendly date widgets are rendered with a specialized CSS tag for enabling JavaScript datepickers.
-
waeup.kofa.widgets.datewidget.
FriendlyDatetimeDisplayWidget
(format)[source]¶ Get a friendly datetime display widget for format.
This widget is suitable for display forms.
Valid format values are the keys of DATE_FORMATS dict. Default is
le
(little endian; DD/MM/YYYY %H:%M:%S).This widget is not rendered with a specialized CSS tag for enabling JavaScript datepickers. css_class is ignored which means there is no difference between e.g.
le
andle-year
.`