Date Selection

The date selection field was designed to support the UI requirement of allowing users to select a date using multi-select input fields. The DateSelect field extends the zope.schema.Date field merely by a few additional attributes.

>>> from z3c.schema.dateselect import field

the first attribute is the range of years that will be offered to the user:

>>> birthday = field.DateSelect(
...     title=u'Birthday',
...     yearRange=list(range(1920, 2007)))

In this case the user will be offered all years from 1920 to 2007.

>>> birthday.yearRange
[1920, ..., 2006]

The second attribute allows you to specify an initial date for the selection:

>>> import datetime
>>> birthday = field.DateSelect(
...     title=u'Birthday',
...     yearRange=range(1920, 2007),
...     initialDate=datetime.date(2000, 1, 1))
>>> birthday.initialDate
datetime.date(2000, 1, 1)

And this is really it. Please read the documentation on the Date for more information.

Reference

class z3c.schema.dateselect.DateSelect(yearRange=None, initialDate=None, **kw)[source]

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')