From b906e684f1c6cc58c7fb2cce0ab3bd5ca6f5f44a Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 8 Mar 2022 22:17:56 +0100 Subject: [PATCH] Switch DatetimePicker start/end to param.Date (#3202) * Switch DatetimePicker start/end to param.Date * Update docs --- .../reference/widgets/DatetimePicker.ipynb | 8 +++--- .../widgets/DatetimeRangePicker.ipynb | 10 +++---- panel/widgets/input.py | 26 ++++++++++++++----- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/examples/reference/widgets/DatetimePicker.ipynb b/examples/reference/widgets/DatetimePicker.ipynb index 7cdc251358..4647bd8219 100644 --- a/examples/reference/widgets/DatetimePicker.ipynb +++ b/examples/reference/widgets/DatetimePicker.ipynb @@ -28,12 +28,12 @@ "##### Core\n", "\n", "* **``value``** (datetime): The selected value as a datetime type\n", - "* **``start``** (date): Start date of the widget\n", - "* **``end``** (date): End date of the widget\n", + "* **``start``** (date or datetime): Inclusive lower bound of the allowed date selection. Note that while the parameter accepts datetimes the time portion of the range is ignored.\n", + "* **``end``** (date or datetime): Inclusive upper bound of the allowed date selection. Note that while the parameter accepts datetimes the time portion of the range is ignored.\n", "* **``disabled_dates``** (list): Dates to make unavailable for selection; others will be available\n", "* **``enabled_dates``** (list): Dates to make available for selection; others will be unavailable\n", - "* **``enable_time:``** (boolean): Enable change of the time in the widget, default is True\n", - "* **``enable_seconds:``** (boolean): Enable change of the seconds in the widget, default is True\n", + "* **``enable_time:``** (boolean): Enable editing of the time in the widget, default is True\n", + "* **``enable_seconds:``**g (boolean): Enable editing of seconds in the widget, default is True\n", "* **``military_time:``** (boolean): Enable 24 hours time in the widget, default is True\n", "\n", "\n", diff --git a/examples/reference/widgets/DatetimeRangePicker.ipynb b/examples/reference/widgets/DatetimeRangePicker.ipynb index 0e3d5d3691..253b501072 100644 --- a/examples/reference/widgets/DatetimeRangePicker.ipynb +++ b/examples/reference/widgets/DatetimeRangePicker.ipynb @@ -28,13 +28,13 @@ "##### Core\n", "\n", "* **``value``** (tuple): Tuple of upper and lower bounds of the selected range expressed as datetime types\n", - "* **``start``** (date): Start date of the widget\n", - "* **``end``** (date): End date of the widget\n", + "* **``start``** (date or datetime): Inclusive lower bound of the allowed date selection. Note that while the parameter accepts datetimes the time portion of the range is ignored.\n", + "* **``end``** (date or datetime): Inclusive upper bound of the allowed date selection. Note that while the parameter accepts datetimes the time portion of the range is ignored.\n", "* **``disabled_dates``** (list): Dates to make unavailable for selection; others will be available\n", "* **``enabled_dates``** (list): Dates to make available for selection; others will be unavailable\n", - "* **``enable_time:``** (boolean): Enable change of the time in the widget, default is True\n", - "* **``enable_seconds:``** (boolean): Enable change of the seconds in the widget, default is True\n", - "* **``military_time:``** (boolean): Enable 24 hours time in the widget, default is True\n", + "* **``enable_time:``** (boolean): Enable editing of the time in the widget, default is True\n", + "* **``enable_seconds:``** (boolean): Enable editing of seconds in the widget, default is True\n", + "* **``military_time:``** (boolean): Whether to display time in 24 hour format, default is True\n", "\n", "\n", "##### Display\n", diff --git a/panel/widgets/input.py b/panel/widgets/input.py index 58a86854f0..a8f5d5b337 100644 --- a/panel/widgets/input.py +++ b/panel/widgets/input.py @@ -166,19 +166,30 @@ def _process_property_change(self, msg): class _DatetimePickerBase(Widget): - start = param.CalendarDate(default=None) + disabled_dates = param.List(default=None, class_=(date, str), doc=""" + Dates to make unavailable for selection.""") - end = param.CalendarDate(default=None) + enabled_dates = param.List(default=None, class_=(date, str), doc=""" + Dates to make available for selection.""") - disabled_dates = param.List(default=None, class_=(date, str)) + enable_time = param.Boolean(default=True, doc=""" + Enable editing of the time in the widget.""") - enabled_dates = param.List(default=None, class_=(date, str)) + enable_seconds = param.Boolean(default=True, doc=""" + Enable editing of the seconds in the widget.""") - enable_time = param.Boolean(default=True) + end = param.Date(default=None, doc=""" + Inclusive upper bound of the allowed date selection. Note that while + the parameter accepts datetimes the time portion of the range + is ignored.""") - enable_seconds = param.Boolean(default=True) + military_time = param.Boolean(default=True, doc=""" + Whether to display time in 24 hour format.""") - military_time = param.Boolean(default=True) + start = param.Date(default=None, doc=""" + Inclusive lower bound of the allowed date selection. Note that while + the parameter accepts datetimes the time portion of the range + is ignored.""") _source_transforms = {'value': None, 'start': None, 'end': None, 'mode': None} @@ -244,6 +255,7 @@ def _deserialize_value(self, value): class DatetimeRangePicker(_DatetimePickerBase): + value = param.DateRange(default=None) mode = param.String('range', constant=True)