1
|
Drupal date_popup.module README.txt
|
2
|
==============================================================================
|
3
|
|
4
|
Javascript popup calendar and timeentry using the
|
5
|
jquery UI calendar and a choice of jquery-timeentry libraries.
|
6
|
|
7
|
================================================================================
|
8
|
Datepicker
|
9
|
================================================================================
|
10
|
|
11
|
This code uses the jQuery UI datepicker that is included in core. Localization
|
12
|
of the interface is handled by core.
|
13
|
|
14
|
The popup will use the site default for the first day of the week.
|
15
|
|
16
|
================================================================================
|
17
|
Timepicker
|
18
|
================================================================================
|
19
|
|
20
|
There are three ways to let users select time in the Date Popup widgets.
|
21
|
You can choose between them by going to admin/config/date/date_popup.
|
22
|
|
23
|
The options are:
|
24
|
|
25
|
1) Manual time entry - a plain textfield where users can type in the time.
|
26
|
2) A 'default' jQuery timepicker, included in the code
|
27
|
(http://keith-wood.name/timeEntry.html).
|
28
|
3) The wvega timepicker (https://github.com/wvega/timepicker).
|
29
|
|
30
|
To install the alternate dropdown (wvega) timepicker:
|
31
|
|
32
|
Create a 'sites/all/libraries/wvega-timepicker' directory in your site
|
33
|
installation. Then visit https://github.com/wvega/timepicker/archives/master,
|
34
|
download the latest copy and unzip it. You will see files with names like
|
35
|
jquery.timepicker-1.1.2.js and jquery.timepicker-1.1.2.css. Rename them to
|
36
|
jquery.timepicker.js and jquery.timepicker.css and copy them into
|
37
|
'sites/all/libraries/wvega-timepicker'.
|
38
|
|
39
|
================================================================================
|
40
|
Usage
|
41
|
================================================================================
|
42
|
|
43
|
To include a popup calendar in a form, use the type 'date_popup':
|
44
|
|
45
|
$form['date'] = array(
|
46
|
'#type' => 'date_popup':
|
47
|
'#title => t('My Date'),
|
48
|
....
|
49
|
);
|
50
|
|
51
|
Set the #type to date_popup and fill the element #default_value with
|
52
|
a date adjusted to the proper local timezone, or leave it blank.
|
53
|
|
54
|
The element will create two textfields, one for the date and one for the
|
55
|
time. The date textfield will include a jQuery popup calendar date picker,
|
56
|
and the time textfield uses a jQuery timepicker.
|
57
|
|
58
|
NOTE - Converting a date stored in the database from UTC to the local zone
|
59
|
and converting it back to UTC before storing it is not handled by this
|
60
|
element and must be done in pre-form and post-form processing!!
|
61
|
|
62
|
================================================================================
|
63
|
Customization
|
64
|
================================================================================
|
65
|
|
66
|
To change the default display and functionality of the calendar, set startup
|
67
|
parameters by adding selectors to your element. The configurable options
|
68
|
are:
|
69
|
|
70
|
#date_type
|
71
|
The type of date to convert the input value to, DATE_DATETIME, DATE_ISO, or
|
72
|
DATE_UNIX
|
73
|
|
74
|
#date_format
|
75
|
a standard PHP date format string that represents the way the month, day,
|
76
|
and year will be displayed in the textfield, like m/d/Y. Months and days
|
77
|
must be in the 'm' and 'd' formats that include the zero prefix, the year
|
78
|
must be in the 'Y' (four digit) format.
|
79
|
|
80
|
Any standard separator can be used, '/', '-', '.', or a space.
|
81
|
|
82
|
The m, d, and Y elements can be in any order and the order will be preserved.
|
83
|
|
84
|
The time selector will add AM/PM if 'a' is in the format string.
|
85
|
|
86
|
The default format uses the short site default format.
|
87
|
|
88
|
#date_year_range
|
89
|
the number of years to go backwards and forwards from current year
|
90
|
in year selector, in the format -{years back}:+{years forward},
|
91
|
like -3:+3
|
92
|
|
93
|
#date_increment
|
94
|
increment minutes and seconds by this amount, default is 1
|
95
|
|
96
|
================================================================================
|
97
|
Example:
|
98
|
================================================================================
|
99
|
|
100
|
$form['date'] = array(
|
101
|
'#type' => 'date_popup',
|
102
|
'#default_value' => '2007-01-01 10:30:00',
|
103
|
'#date_type' => DATE_DATETIME,
|
104
|
'#date_timezone' => date_default_timezone(),
|
105
|
'#date_format' => 'm-d-Y H:i',
|
106
|
'#date_increment' => 1,
|
107
|
'#date_year_range' => '-3:+3',
|
108
|
);
|