daterangepicker-4.x 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +161 -0
- package/bower.json +20 -0
- package/daterangepicker-moment.js +1712 -0
- package/daterangepicker.css +429 -0
- package/daterangepicker.js +2368 -0
- package/daterangepicker.md +640 -0
- package/demo.html +411 -0
- package/drp.png +0 -0
- package/example/amd/index.html +210 -0
- package/example/amd/main.js +141 -0
- package/example/amd/require.js +36 -0
- package/example/browserify/README.md +11 -0
- package/example/browserify/bundle.js +0 -0
- package/example/browserify/index.html +209 -0
- package/example/browserify/main.js +135 -0
- package/index.html +103 -0
- package/package.json +30 -0
- package/website/index.html +745 -0
- package/website/website.css +152 -0
- package/website/website.js +179 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012-2019 Dan Grossman
|
|
4
|
+
Copyright (c) 2025 Wernfried Domscheit
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Date Range Picker
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
This date range picker component creates a dropdown menu from which a user can
|
|
6
|
+
select a range of dates.
|
|
7
|
+
|
|
8
|
+
Features include limiting the selectable date range, localizable strings and date formats,
|
|
9
|
+
a single date picker mode, a time picker, and predefined date ranges.
|
|
10
|
+
|
|
11
|
+
### [Documentation and Live Usage Examples](http://www.daterangepicker.com)
|
|
12
|
+
|
|
13
|
+
### [See It In a Live Application](https://awio.iljmp.com/5/drpdemogh)
|
|
14
|
+
|
|
15
|
+
Above samples are based on the [original repository](https://github.com/dangrossman/daterangepicker) from Dan Grossman. [New features](#Features) from this fork are not available in these samples.
|
|
16
|
+
|
|
17
|
+
## Basic usage
|
|
18
|
+
```
|
|
19
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
|
|
20
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
|
|
21
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/Wernfried/daterangepicker@master/daterangepicker.min.js"></script>
|
|
22
|
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/Wernfried/daterangepicker@master/daterangepicker.min.css" />
|
|
23
|
+
|
|
24
|
+
<! --https://cdn.jsdelivr.net/npm/daterangepickerg@4.0.1/daterangepicker.min.js -->
|
|
25
|
+
|
|
26
|
+
<input type="text" id="daterange" />
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
$(function() {
|
|
30
|
+
const options = {
|
|
31
|
+
timePicker: true
|
|
32
|
+
}
|
|
33
|
+
$('#daterange').daterangepicker(options);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API Documentation
|
|
39
|
+
|
|
40
|
+
### Options
|
|
41
|
+
|
|
42
|
+
See [Options](daterangepicker.md#Options)
|
|
43
|
+
|
|
44
|
+
See [Options.locale](daterangepicker.md#Options.Locale)
|
|
45
|
+
|
|
46
|
+
### Methods
|
|
47
|
+
|
|
48
|
+
- [setStartDate(startDate)](daterangepicker.md#DateRangePicker+setStartDate)
|
|
49
|
+
- [setEndDate(endDate)](daterangepicker.md#DateRangePicker+setEndDate)
|
|
50
|
+
- [setPeriod(startDate, endDate)](daterangepicker.md#DateRangePicker+setPeriod)
|
|
51
|
+
|
|
52
|
+
### Events
|
|
53
|
+
|
|
54
|
+
See [Events](daterangepicker.md)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Examples
|
|
58
|
+
### `ranges`
|
|
59
|
+
<a name="options-ranges"></a>
|
|
60
|
+
```
|
|
61
|
+
{
|
|
62
|
+
'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
|
|
63
|
+
'Yesterday': [DateTime.now().startOf('day').minus({day: 1}), DateTime.now().endOf('day').minus({day: 1})],
|
|
64
|
+
'Last 7 Days': ['2025-03-01', '2025-03-07'],
|
|
65
|
+
'Last 30 Days': [new Date(new Date - 1000*60*60*24*30), new Date()],
|
|
66
|
+
'This Month': [DateTime.now().startOf('month'), DateTime.now().endOf('month')],
|
|
67
|
+
'Last Month': [DateTime.now().minus({month: 1}).startOf('month'), DateTime.now().minus({month: 1}).endOf('month')]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `isInvalidDate`
|
|
72
|
+
```
|
|
73
|
+
isInvalidDate: function(date) {
|
|
74
|
+
return date.isWeekend;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `isInvalidTime`
|
|
79
|
+
```
|
|
80
|
+
const validRange = [DateTime.fromSQL('2025-03-01 11:30'), DateTime.fromSQL('2025-04-21 18:30')];
|
|
81
|
+
|
|
82
|
+
isInvalidTime: (time, side, unit) => {
|
|
83
|
+
if (side == 'start' && time.hasSame(validRange[0], 'day')) {
|
|
84
|
+
if (unit == 'hour') {
|
|
85
|
+
return time.hour < validRange[0].hour;
|
|
86
|
+
} else {
|
|
87
|
+
return time.hasSame(validRange[0], 'hour') ? time.minute < validRange[0].minute : false;
|
|
88
|
+
}
|
|
89
|
+
} else if (side == 'end' && t.hasSame(validRange[1], 'day')) {
|
|
90
|
+
if (unit == 'hour') {
|
|
91
|
+
return time.hour > validRange[1].hour;
|
|
92
|
+
} else {
|
|
93
|
+
return time.hasSame(validRange[1], 'hour') ? time.minute > validRange[1].minute : false;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `isCustomDate`
|
|
102
|
+
```
|
|
103
|
+
.daterangepicker-bank-day {
|
|
104
|
+
color: red;
|
|
105
|
+
}
|
|
106
|
+
.daterangepicker-weekend-day {
|
|
107
|
+
color: blue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
isInvalidDate: function(date) {
|
|
111
|
+
if (date.isWeekend)
|
|
112
|
+
return 'daterangepicker-weekend-day';
|
|
113
|
+
|
|
114
|
+
const yyyy = date.year;
|
|
115
|
+
let bankDays = [
|
|
116
|
+
DateTime.fromObject({ year: yyyy, month: 1, day: 1 }), // New year
|
|
117
|
+
DateTime.fromObject({ year: yyyy, month: 7, day: 4 }), // Independence Day
|
|
118
|
+
DateTime.fromObject({ year: yyyy, month: 12, day: 25 }) // Christmas Day
|
|
119
|
+
];
|
|
120
|
+
return bankDays.some(x => x.hasSame(date, 'day')) ? 'daterangepicker-bank-day' : '';
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
### Features
|
|
124
|
+
Compared to [inital repository](https://github.com/dangrossman/daterangepicker), this fork added following features:
|
|
125
|
+
|
|
126
|
+
- Added CSS class `weekend-day` for weekend days in calendar
|
|
127
|
+
- Added option `timePickerStepSize` to succeed options `timePickerIncrement` and `timePickerSeconds`
|
|
128
|
+
- Added events for `dateChange.daterangepicker` and `timeChange.daterangepicker`
|
|
129
|
+
- Added method `setRange` to combine `setStartDate` and `setEndDate`
|
|
130
|
+
- Added option `minSpan` similar to `maxSpan`
|
|
131
|
+
- Added option `isInvalidTime` similar to `isInvalidDate`
|
|
132
|
+
- Replaced [moment](https://momentjs.com/) by [luxon](https://moment.github.io/luxon/index.html)
|
|
133
|
+
- Better validation of input parameters, error are printed to console
|
|
134
|
+
- Highlight range in calendar when hovering over pre-defined ranges
|
|
135
|
+
- Added option `locale.durationLabel` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
|
|
136
|
+
- ... and maybe some new bugs 😉
|
|
137
|
+
|
|
138
|
+
### Differences between `moment` and `luxon` library
|
|
139
|
+
This table lists a few important differences between datarangepicker using moment and luxon. Check them carefully when you migrate from older daterangepicker.
|
|
140
|
+
|
|
141
|
+
| Parameter | moment | luxon |
|
|
142
|
+
| ----------------------- | --------------------------------------------------- | ----------------- |
|
|
143
|
+
| `locale.daysOfWeek` | [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] | [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] |
|
|
144
|
+
| `locale.firstDay` | 0-6 (Sunday to Saturday) | 1 for Monday through 7 for Sunday |
|
|
145
|
+
| to ISO-8601 String | `toISOString()` | `toISO()` |
|
|
146
|
+
| to [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `toDate()` | `toJSDate()` |
|
|
147
|
+
| from ISO-8601 String | `moment(...)` | `DateIme.fromISO(...)` |
|
|
148
|
+
| from [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `moment(...)` | `DateIme.fromJSDate(...)` |
|
|
149
|
+
| current day | `moment()` | `DateTime.now()` |
|
|
150
|
+
| format to string | `format(...)`` | `toFormat(...)` |
|
|
151
|
+
| format tokens | `'YYYY-MM-DD'` | `'yyyy-MM-dd'` |
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
The MIT License (MIT)
|
|
157
|
+
|
|
158
|
+
Copyright (c) 2012-2019 Dan Grossman<br/>
|
|
159
|
+
Copyright (c) 2025 Wernfried Domscheit
|
|
160
|
+
|
|
161
|
+
Licensed under the [MIT license](LICENSE).
|
package/bower.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "daterangepicker",
|
|
3
|
+
"main": [
|
|
4
|
+
"daterangepicker.js",
|
|
5
|
+
"daterangepicker.css"
|
|
6
|
+
],
|
|
7
|
+
"ignore": [
|
|
8
|
+
"**/.*",
|
|
9
|
+
"node_modules",
|
|
10
|
+
"bower_components",
|
|
11
|
+
"test",
|
|
12
|
+
"tests",
|
|
13
|
+
"moment.js",
|
|
14
|
+
"moment.min.js"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"jquery": "1.9.1 - 3",
|
|
18
|
+
"moment": ">=2.9.0"
|
|
19
|
+
}
|
|
20
|
+
}
|