daterangepicker-4.x 4.1.7 → 4.1.9

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/README.md CHANGED
@@ -1,149 +1,149 @@
1
- # Date Range Picker
2
-
3
- ![Improvely.com](https://i.imgur.com/UTRlaar.png)
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
- ```html
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/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
21
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.7/daterangepicker.min.js"></script>
22
- <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.7/daterangepicker.min.css" rel="stylesheet" />
23
-
24
- <input type="text" id="daterange" />
25
-
26
- <script>
27
- $(function() {
28
- const options = {
29
- timePicker: true
30
- }
31
- $('#daterange').daterangepicker(options);
32
- });
33
-
34
- ```
35
-
36
- ## Examples
37
- ### `ranges`
38
- <a name="options-ranges"></a>
39
- ```js
40
- {
41
- 'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
42
- 'Yesterday': [DateTime.now().startOf('day').minus({day: 1}), DateTime.now().endOf('day').minus({day: 1})],
43
- 'Last 7 Days': ['2025-03-01', '2025-03-07'],
44
- 'Last 30 Days': [new Date(new Date - 1000*60*60*24*30), new Date()],
45
- 'This Month': [DateTime.now().startOf('month'), DateTime.now().endOf('month')],
46
- 'Last Month': [DateTime.now().minus({month: 1}).startOf('month'), DateTime.now().minus({month: 1}).endOf('month')]
47
- }
48
- ```
49
-
50
- ### `isInvalidDate`
51
- ```js
52
- isInvalidDate: function(date) {
53
- return date.isWeekend;
54
- }
55
- ```
56
-
57
- ### `isInvalidTime`
58
- ```js
59
- const validRange = [DateTime.fromSQL('2025-03-01 11:30'), DateTime.fromSQL('2025-04-21 18:30')];
60
-
61
- isInvalidTime: (time, side, unit) => {
62
- if (side == 'start' && time.hasSame(validRange[0], 'day')) {
63
- if (unit == 'hour') {
64
- return time.hour < validRange[0].hour;
65
- } else {
66
- return time.hasSame(validRange[0], 'hour') ? time.minute < validRange[0].minute : false;
67
- }
68
- } else if (side == 'end' && t.hasSame(validRange[1], 'day')) {
69
- if (unit == 'hour') {
70
- return time.hour > validRange[1].hour;
71
- } else {
72
- return time.hasSame(validRange[1], 'hour') ? time.minute > validRange[1].minute : false;
73
- }
74
- } else {
75
- return false;
76
- }
77
- }
78
- ```
79
-
80
- ### `isCustomDate`
81
- ```js
82
- .daterangepicker-bank-day {
83
- color: red;
84
- }
85
- .daterangepicker-weekend-day {
86
- color: blue;
87
- }
88
-
89
- isInvalidDate: function(date) {
90
- if (date.isWeekend)
91
- return 'daterangepicker-weekend-day';
92
-
93
- const yyyy = date.year;
94
- let bankDays = [
95
- DateTime.fromObject({ year: yyyy, month: 1, day: 1 }), // New year
96
- DateTime.fromObject({ year: yyyy, month: 7, day: 4 }), // Independence Day
97
- DateTime.fromObject({ year: yyyy, month: 12, day: 25 }) // Christmas Day
98
- ];
99
- return bankDays.some(x => x.hasSame(date, 'day')) ? 'daterangepicker-bank-day' : '';
100
- }
101
- ```
102
- ### Features
103
- Compared to [inital repository](https://github.com/dangrossman/daterangepicker), this fork added following features and changes:
104
-
105
- - Replaced [moment](https://momentjs.com/) by [luxon](https://moment.github.io/luxon/index.html) (see differences below)
106
- - Added CSS class `weekend-day` for weekend days in calendar
107
- - Added option `timePickerStepSize` to succeed options `timePickerIncrement` and `timePickerSeconds`
108
- - Added events `dateChange.daterangepicker` and `timeChange.daterangepicker` emitted when user clicks on a date/time
109
- - Added event `beforeHide.daterangepicker` enables you to keep the picker visible after click on `Apply` or `Cancel` button.
110
- - Added method `setRange(startDate, endDate)` to combine `setStartDate(startDate)` and `setEndDate(endDate)`
111
- - Added option `minSpan` similar to `maxSpan`
112
- - Added option `isInvalidTime` similar to `isInvalidDate`
113
- - Added option `onOutsideClick` where you can define whether picker shall apply or revert selected value
114
- - Better validation of input parameters, errors are logged to console
115
- - Highlight range in calendar when hovering over pre-defined ranges
116
- - Option `autoUpdateInput` defines whether the attached `<input>` element is updated when the user clicks on a date value.<br/>
117
- In original daterangepicker this parameter defines whether the `<input>` is updated when the user clicks on `Apply` button.
118
- - Added option `locale.durationFormat` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
119
- - ... and maybe some new bugs 😉
120
-
121
- ### Differences between `moment` and `luxon` library
122
- This table lists a few important differences between datarangepicker using moment and luxon. Check them carefully when you migrate from older daterangepicker.
123
-
124
- | Parameter | moment | luxon |
125
- | ----------------------- | --------------------------------------------------- | ----------------- |
126
- | `locale.daysOfWeek` | [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] | [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] |
127
- | `locale.firstDay` | 0-6 (Sunday to Saturday) | 1 for Monday through 7 for Sunday |
128
- | to ISO-8601 String | `toISOString()` | `toISO()` |
129
- | to [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `toDate()` | `toJSDate()` |
130
- | from ISO-8601 String | `moment(...)` | `DateIme.fromISO(...)` |
131
- | from [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `moment(...)` | `DateIme.fromJSDate(...)` |
132
- | current day | `moment()` | `DateTime.now()` |
133
- | format to string | `format(...)` | `toFormat(...)` |
134
- | format tokens | `'YYYY-MM-DD'` | `'yyyy-MM-dd'` |
135
-
136
-
137
- ## License
138
-
139
- The MIT License (MIT)
140
-
141
- Copyright (c) 2012-2019 Dan Grossman<br/>
142
- Copyright (c) 2025 Wernfried Domscheit
143
-
144
- Licensed under the [MIT license](LICENSE).
145
-
146
- # API Documentation
1
+ # Date Range Picker
2
+
3
+ ![Improvely.com](https://i.imgur.com/UTRlaar.png)
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
+ ```html
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/npm/luxon@3.5.0/build/global/luxon.min.js"></script>
21
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.9/daterangepicker.min.js"></script>
22
+ <link type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker-4.x@4.1.9/daterangepicker.min.css" rel="stylesheet" />
23
+
24
+ <input type="text" id="daterange" />
25
+
26
+ <script>
27
+ $(function() {
28
+ const options = {
29
+ timePicker: true
30
+ }
31
+ $('#daterange').daterangepicker(options);
32
+ });
33
+
34
+ ```
35
+
36
+ ## Examples
37
+ ### `ranges`
38
+ <a name="options-ranges"></a>
39
+ ```js
40
+ {
41
+ 'Today': [DateTime.now().startOf('day'), DateTime.now().endOf('day')],
42
+ 'Yesterday': [DateTime.now().startOf('day').minus({day: 1}), DateTime.now().endOf('day').minus({day: 1})],
43
+ 'Last 7 Days': ['2025-03-01', '2025-03-07'],
44
+ 'Last 30 Days': [new Date(new Date - 1000*60*60*24*30), new Date()],
45
+ 'This Month': [DateTime.now().startOf('month'), DateTime.now().endOf('month')],
46
+ 'Last Month': [DateTime.now().minus({month: 1}).startOf('month'), DateTime.now().minus({month: 1}).endOf('month')]
47
+ }
48
+ ```
49
+
50
+ ### `isInvalidDate`
51
+ ```js
52
+ isInvalidDate: function(date) {
53
+ return date.isWeekend;
54
+ }
55
+ ```
56
+
57
+ ### `isInvalidTime`
58
+ ```js
59
+ const validRange = [DateTime.fromSQL('2025-03-01 11:30'), DateTime.fromSQL('2025-04-21 18:30')];
60
+
61
+ isInvalidTime: (time, side, unit) => {
62
+ if (side == 'start' && time.hasSame(validRange[0], 'day')) {
63
+ if (unit == 'hour') {
64
+ return time.hour < validRange[0].hour;
65
+ } else {
66
+ return time.hasSame(validRange[0], 'hour') ? time.minute < validRange[0].minute : false;
67
+ }
68
+ } else if (side == 'end' && t.hasSame(validRange[1], 'day')) {
69
+ if (unit == 'hour') {
70
+ return time.hour > validRange[1].hour;
71
+ } else {
72
+ return time.hasSame(validRange[1], 'hour') ? time.minute > validRange[1].minute : false;
73
+ }
74
+ } else {
75
+ return false;
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### `isCustomDate`
81
+ ```js
82
+ .daterangepicker-bank-day {
83
+ color: red;
84
+ }
85
+ .daterangepicker-weekend-day {
86
+ color: blue;
87
+ }
88
+
89
+ isInvalidDate: function(date) {
90
+ if (date.isWeekend)
91
+ return 'daterangepicker-weekend-day';
92
+
93
+ const yyyy = date.year;
94
+ let bankDays = [
95
+ DateTime.fromObject({ year: yyyy, month: 1, day: 1 }), // New year
96
+ DateTime.fromObject({ year: yyyy, month: 7, day: 4 }), // Independence Day
97
+ DateTime.fromObject({ year: yyyy, month: 12, day: 25 }) // Christmas Day
98
+ ];
99
+ return bankDays.some(x => x.hasSame(date, 'day')) ? 'daterangepicker-bank-day' : '';
100
+ }
101
+ ```
102
+ ### Features
103
+ Compared to [inital repository](https://github.com/dangrossman/daterangepicker), this fork added following features and changes:
104
+
105
+ - Replaced [moment](https://momentjs.com/) by [luxon](https://moment.github.io/luxon/index.html) (see differences below)
106
+ - Added CSS class `weekend-day` for weekend days in calendar
107
+ - Added option `timePickerStepSize` to succeed options `timePickerIncrement` and `timePickerSeconds`
108
+ - Added events `dateChange.daterangepicker` and `timeChange.daterangepicker` emitted when user clicks on a date/time
109
+ - Added event `beforeHide.daterangepicker` enables you to keep the picker visible after click on `Apply` or `Cancel` button.
110
+ - Added method `setRange(startDate, endDate)` to combine `setStartDate(startDate)` and `setEndDate(endDate)`
111
+ - Added option `minSpan` similar to `maxSpan`
112
+ - Added option `isInvalidTime` similar to `isInvalidDate`
113
+ - Added option `onOutsideClick` where you can define whether picker shall apply or revert selected value
114
+ - Better validation of input parameters, errors are logged to console
115
+ - Highlight range in calendar when hovering over pre-defined ranges
116
+ - Option `autoUpdateInput` defines whether the attached `<input>` element is updated when the user clicks on a date value.<br/>
117
+ In original daterangepicker this parameter defines whether the `<input>` is updated when the user clicks on `Apply` button.
118
+ - Added option `locale.durationFormat` to show customized label for selected duration, e.g. `'4 Days, 6 Hours, 30 Minutes'`
119
+ - ... and maybe some new bugs 😉
120
+
121
+ ### Differences between `moment` and `luxon` library
122
+ This table lists a few important differences between datarangepicker using moment and luxon. Check them carefully when you migrate from older daterangepicker.
123
+
124
+ | Parameter | moment | luxon |
125
+ | ----------------------- | --------------------------------------------------- | ----------------- |
126
+ | `locale.daysOfWeek` | [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] | [ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ] |
127
+ | `locale.firstDay` | 0-6 (Sunday to Saturday) | 1 for Monday through 7 for Sunday |
128
+ | to ISO-8601 String | `toISOString()` | `toISO()` |
129
+ | to [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `toDate()` | `toJSDate()` |
130
+ | from ISO-8601 String | `moment(...)` | `DateIme.fromISO(...)` |
131
+ | from [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) Object | `moment(...)` | `DateIme.fromJSDate(...)` |
132
+ | current day | `moment()` | `DateTime.now()` |
133
+ | format to string | `format(...)` | `toFormat(...)` |
134
+ | format tokens | `'YYYY-MM-DD'` | `'yyyy-MM-dd'` |
135
+
136
+
137
+ ## License
138
+
139
+ The MIT License (MIT)
140
+
141
+ Copyright (c) 2012-2019 Dan Grossman<br/>
142
+ Copyright (c) 2025 Wernfried Domscheit
143
+
144
+ Licensed under the [MIT license](LICENSE).
145
+
146
+ # API Documentation
147
147
  ## Classes
148
148
 
149
149
  <dl>
@@ -215,9 +215,9 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
215
215
  * [DateRangePicker](#DateRangePicker)
216
216
  * [new DateRangePicker(element, options, cb)](#new_DateRangePicker_new)
217
217
  * _instance_
218
- * [.setStartDate(startDate)](#DateRangePicker+setStartDate)
219
- * [.setEndDate(endDate)](#DateRangePicker+setEndDate)
220
- * [.setPeriod(startDate, endDate)](#DateRangePicker+setPeriod)
218
+ * [.setStartDate(startDate, isValid)](#DateRangePicker+setStartDate)
219
+ * [.setEndDate(endDate, isValid)](#DateRangePicker+setEndDate)
220
+ * [.setPeriod(startDate, endDate, isValid)](#DateRangePicker+setPeriod)
221
221
  * [.updateView()](#DateRangePicker+updateView)
222
222
  * [.outsideClick(e)](#DateRangePicker+outsideClick)
223
223
  * _static_
@@ -235,7 +235,7 @@ use <a href="#event_timeChange.daterangepicker">&quot;timeChange.daterangepicker
235
235
 
236
236
  <a name="DateRangePicker+setStartDate"></a>
237
237
 
238
- ### dateRangePicker.setStartDate(startDate)
238
+ ### dateRangePicker.setStartDate(startDate, isValid)
239
239
  Sets the date range picker's currently selected start date to the provided date.<br/>
240
240
  `startDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or
241
241
  a string matching `locale.format`.
@@ -250,9 +250,10 @@ If the `startDate` does not fall into `minDate` and `maxDate` then `startDate` i
250
250
  - `RangeError` for invalid date values.
251
251
 
252
252
 
253
- | Param | Type | Description |
254
- | --- | --- | --- |
255
- | startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | startDate to be set |
253
+ | Param | Type | Default | Description |
254
+ | --- | --- | --- | --- |
255
+ | startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | | startDate to be set |
256
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `startDate` is not checked against `minDate` and `maxDate`<br/> Use this option only if you are really sure about the value you put in. |
256
257
 
257
258
  **Example**
258
259
  ```js
@@ -262,7 +263,7 @@ drp.setStartDate(DateTime.now().startOf('hour'));
262
263
  ```
263
264
  <a name="DateRangePicker+setEndDate"></a>
264
265
 
265
- ### dateRangePicker.setEndDate(endDate)
266
+ ### dateRangePicker.setEndDate(endDate, isValid)
266
267
  Sets the date range picker's currently selected end date to the provided date.<br/>
267
268
  `endDate` must be a `luxon.DateTime` or `Date` or `string` according to [ISO-8601](ISO-8601) or
268
269
  a string matching`locale.format`.
@@ -278,9 +279,10 @@ then `endDate` is shifted and a warning is written to console.
278
279
  - `RangeError` for invalid date values.
279
280
 
280
281
 
281
- | Param | Type | Description |
282
- | --- | --- | --- |
283
- | endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | endDate to be set |
282
+ | Param | Type | Default | Description |
283
+ | --- | --- | --- | --- |
284
+ | endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | | endDate to be set |
285
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `endDate` is not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/> Use this option only if you are really sure about the value you put in. |
284
286
 
285
287
  **Example**
286
288
  ```js
@@ -289,7 +291,7 @@ drp.setEndDate('2025-03-28T18:30:00');
289
291
  ```
290
292
  <a name="DateRangePicker+setPeriod"></a>
291
293
 
292
- ### dateRangePicker.setPeriod(startDate, endDate)
294
+ ### dateRangePicker.setPeriod(startDate, endDate, isValid)
293
295
  Shortcut for [setStartDate](#DateRangePicker+setStartDate) and [setEndDate](#DateRangePicker+setEndDate)
294
296
 
295
297
  **Kind**: instance method of [<code>DateRangePicker</code>](#DateRangePicker)
@@ -298,10 +300,11 @@ Shortcut for [setStartDate](#DateRangePicker+setStartDate) and [setEndDate](#Dat
298
300
  - `RangeError` for invalid date values.
299
301
 
300
302
 
301
- | Param | Type | Description |
302
- | --- | --- | --- |
303
- | startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | startDate to be set |
304
- | endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | endDate to be set |
303
+ | Param | Type | Default | Description |
304
+ | --- | --- | --- | --- |
305
+ | startDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | | startDate to be set |
306
+ | endDate | [<code>DateTime</code>](https://moment.github.io/luxon/api-docs/index.html#datetime) \| [<code>Date</code>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) \| <code>string</code> | | endDate to be set |
307
+ | isValid | <code>boolean</code> | <code>false</code> | If `true` then the `startDate` and `endDate` are not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/> Use this option only if you are really sure about the value you put in. |
305
308
 
306
309
  **Example**
307
310
  ```js
@@ -685,12 +685,14 @@
685
685
  * Functions `isInvalidDate` and `isInvalidTime` are not evaluated, you may set date/time which is not selectable in calendar.<br/>
686
686
  * If the `startDate` does not fall into `minDate` and `maxDate` then `startDate` is shifted and a warning is written to console.
687
687
  * @param {external:DateTime|external:Date|string} startDate - startDate to be set
688
+ * @param {boolean} isValid=false - If `true` then the `startDate` is not checked against `minDate` and `maxDate`<br/>
689
+ * Use this option only if you are really sure about the value you put in.
688
690
  * @throws `RangeError` for invalid date values.
689
691
  * @example const DateTime = luxon.DateTime;
690
692
  * const drp = $('#picker').data('daterangepicker');
691
693
  * drp.setStartDate(DateTime.now().startOf('hour'));
692
694
  */
693
- setStartDate: function (startDate, isValid) {
695
+ setStartDate: function (startDate, isValid = false) {
694
696
  // If isValid == true, then value is selected from calendar and stepSize, minDate, maxDate are already considered
695
697
  if (isValid === undefined || !isValid) {
696
698
  if (typeof startDate === 'object') {
@@ -734,11 +736,13 @@
734
736
  * If the `endDate` does not fall into `minDate` and `maxDate` or into `minSpan` and `maxSpan`
735
737
  * then `endDate` is shifted and a warning is written to console.
736
738
  * @param {external:DateTime|external:Date|string} endDate - endDate to be set
739
+ * @param {boolean} isValid=false - If `true` then the `endDate` is not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/>
740
+ * Use this option only if you are really sure about the value you put in.
737
741
  * @throws `RangeError` for invalid date values.
738
742
  * @example const drp = $('#picker').data('daterangepicker');
739
743
  * drp.setEndDate('2025-03-28T18:30:00');
740
744
  */
741
- setEndDate: function (endDate, isValid) {
745
+ setEndDate: function (endDate, isValid = false) {
742
746
  // If isValid == true, then value is selected from calendar and stepSize, minDate, maxDate are already considered
743
747
  if (isValid === undefined || !isValid) {
744
748
  if (typeof endDate === 'object') {
@@ -792,17 +796,21 @@
792
796
  * Shortcut for {@link #DateRangePicker+setStartDate|setStartDate} and {@link #DateRangePicker+setEndDate|setEndDate}
793
797
  * @param {external:DateTime|external:Date|string} startDate - startDate to be set
794
798
  * @param {external:DateTime|external:Date|string} endDate - endDate to be set
799
+ * @param {boolean} isValid=false - If `true` then the `startDate` and `endDate` are not checked against `minDate`, `maxDate` and `minSpan`, `maxSpan`<br/>
800
+ * Use this option only if you are really sure about the value you put in.
795
801
  * @throws `RangeError` for invalid date values.
796
802
  * @example const DateTime = luxon.DateTime;
797
803
  * const drp = $('#picker').data('daterangepicker');
798
804
  * drp.setPeriod(DateTime.now().startOf('week'), DateTime.now().startOf('week').plus({days: 10}));
799
805
  */
800
- setPeriod: function (startDate, endDate) {
806
+ setPeriod: function (startDate, endDate, isValid = false) {
801
807
  if (this.singleDatePicker) {
802
- this.setStartDate(startDate, false);
808
+ this.setStartDate(startDate, isValid);
803
809
  } else {
804
- this.setStartDate(startDate, false);
805
- this.setEndDate(endDate, false);
810
+ this.setStartDate(startDate, true);
811
+ this.setEndDate(endDate, true);
812
+ if (!isValid)
813
+ this.constrainDate();
806
814
  }
807
815
  },
808
816
 
@@ -898,6 +906,9 @@
898
906
  }
899
907
  }
900
908
 
909
+ if (endDate == null)
910
+ return;
911
+
901
912
  if (stepSize && this.timePicker) {
902
913
  // Round time to step size
903
914
  const secs = this.timePickerStepSize.as('seconds');
@@ -2357,7 +2368,7 @@
2357
2368
  * @param {external:DateTime} endDate - Selected endDate
2358
2369
  * @param {string} range
2359
2370
  */
2360
-
2371
+
2361
2372
  /**
2362
2373
  * Initiate a new DateRangePicker
2363
2374
  * @name DateRangePicker.daterangepicker
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "daterangepicker-4.x",
3
- "version": "4.1.7",
3
+ "version": "4.1.9",
4
4
  "description": "Date range picker with time component and pre-defined ranges",
5
5
  "main": "daterangepicker.js",
6
6
  "style": "daterangepicker.css",
7
7
  "scripts": {
8
- "postversion": "sed -i -e 's/daterangepicker-4.x@4\\.[0-9]\\+\\.[0-9]\\+/daterangepicker-4.x@%npm_package_version%/' README.md",
9
- "prepack": "sed -i '/# API Documentation/q' README.md",
8
+ "postversion": "sed -bi -e 's/daterangepicker-4.x@4\\.[0-9]\\+\\.[0-9]\\+/daterangepicker-4.x@%npm_package_version%/' README.md",
9
+ "prepack": "sed -bi '/# API Documentation/q' README.md",
10
10
  "prepare": "jsdoc2md --EOL win32 --example-lang js daterangepicker.js >> README.md",
11
11
  "postpack": "git commit -a -m \"Updated README.md\""
12
12
  },