Package s3 :: Module s3widgets :: Class S3CalendarWidget
[frames] | no frames]

Class S3CalendarWidget

source code

??-284 --+
         |
        S3CalendarWidget


Widget to select a date from a popup calendar, with
optional time input

@note: this widget must be combined with the IS_UTC_DATE or
       IS_UTC_DATETIME validators to have the value properly
       converted from/to local timezone and format.

- control script is s3.ui.calendar.js
- uses jQuery UI DatePicker for Gregorian calendars: https://jqueryui.com/datepicker/
- uses jQuery UI Timepicker-addon if using times: http://trentrichardson.com/examples/timepicker
- uses Calendars for non-Gregorian calendars: http://keith-wood.name/calendars.html
    (for this, ensure that css.cfg includes calendars/ui.calendars.picker.css and
                                            calendars/ui-smoothness.calendars.picker.css)

Instance Methods
 
__init__(self, calendar=None, date_format=None, time_format=None, separator=None, minimum=None, maximum=None, past=None, future=None, past_months=None, future_months=None, month_selector=False, year_selector=True, min_year=None, max_year=None, week_number=False, buttons=None, timepicker=False, minute_step=5, set_min=None, set_max=None, clear_text=None)
Constructor
source code
 
__call__(self, field, value, **attributes)
Widget builder
source code
 
extremes(self, dtformat=None)
Compute the minimum/maximum selectable date/time, as well as the default time (=the minute-step closest to now)
source code
 
inject_script(self, selector, options)
Helper function to inject the document-ready-JavaScript for this widget.
source code
Method Details

__init__(self, calendar=None, date_format=None, time_format=None, separator=None, minimum=None, maximum=None, past=None, future=None, past_months=None, future_months=None, month_selector=False, year_selector=True, min_year=None, max_year=None, week_number=False, buttons=None, timepicker=False, minute_step=5, set_min=None, set_max=None, clear_text=None)
(Constructor)

source code 

Constructor

Parameters:
  • calendar - which calendar to use (override default)
  • date_format - the date format (override default)
  • time_format - the time format (override default)
  • separator - date-time separator (override default)
  • minimum - the minimum selectable date/time (overrides past)
  • maximum - the maximum selectable date/time (overrides future)
  • past - how many hours into the past are selectable (overrides past_months)
  • future - how many hours into the future are selectable (overrides future_months)
  • past_months - how many months into the past are selectable
  • future_months - how many months into the future are selectable
  • month_selector - show a months drop-down
  • year_selector - show a years drop-down
  • min_year - the minimum selectable year (can be relative to now like "-10")
  • max_year - the maximum selectable year (can be relative to now like "+10")
  • week_number - show the week number in the calendar
  • buttons - show the button panel (defaults to True if the widget has a timepicker, else False)
  • timepicker - show a timepicker
  • minute_step - minute-step for the timepicker slider
  • set_min - CSS selector for another S3Calendar widget for which to dynamically update the minimum selectable date/time from the selected date/time of this widget
  • set_max - CSS selector for another S3Calendar widget for which to dynamically update the maximum selectable date/time from the selected date/time of this widget

__call__(self, field, value, **attributes)
(Call operator)

source code 

Widget builder

Parameters:
  • field - the Field
  • value - the current value
  • attributes - the HTML attributes for the widget

extremes(self, dtformat=None)

source code 

Compute the minimum/maximum selectable date/time, as well as the default time (=the minute-step closest to now)

Parameters:
  • dtformat - the user datetime format
Returns:
a dict {minDateTime, maxDateTime, defaultValue, yearRange} with the min/max options as ISO-formatted strings, and the defaultValue in user-format (all in local time), to be passed as-is to s3.calendarwidget

inject_script(self, selector, options)

source code 

Helper function to inject the document-ready-JavaScript for this widget.

Parameters:
  • field - the Field
  • value - the current value
  • attr - the HTML attributes for the widget