From a1425a67a0ff6f337cc5a655a308aee7efb4b0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=BCtfi=20Alt=C4=B1n?= Date: Sun, 18 Oct 2015 15:02:19 +0300 Subject: [PATCH 1/2] add getter methods for date limits --- js/bootstrap-datepicker.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/bootstrap-datepicker.js b/js/bootstrap-datepicker.js index 08f1a2d..65f5f0d 100644 --- a/js/bootstrap-datepicker.js +++ b/js/bootstrap-datepicker.js @@ -636,6 +636,10 @@ return DPGlobal.formatDate(d, format, lang); }).join(this.o.multidateSeparator); }, + + getStartDate: function(){ + return this._utc_to_local(this.o.startDate); + }, setStartDate: function(startDate){ this._process_options({startDate: startDate}); @@ -643,6 +647,10 @@ this.updateNavArrows(); return this; }, + + getEndDate: function(){ + return this._utc_to_local(this.o.endDate); + }, setEndDate: function(endDate){ this._process_options({endDate: endDate}); From 34af22058440a2513dc168ac3312d6cca8518527 Mon Sep 17 00:00:00 2001 From: laltin Date: Tue, 24 Nov 2015 11:59:07 +0200 Subject: [PATCH 2/2] added docs & tests. bugfix --- docs/methods.rst | 16 ++++++++++++++++ js/bootstrap-datepicker.js | 4 ++-- tests/suites/methods.js | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/methods.rst b/docs/methods.rst index 2ccd3ab..5ce911a 100644 --- a/docs/methods.rst +++ b/docs/methods.rst @@ -144,6 +144,22 @@ Arguments: None Returns the internal list of UTC date objects, as they are and unconverted to local time, of the first datepicker in the selection. For use with multidate pickers. +getStartDate +------------ + +Arguments: None + +Returns the lower date limit on the datepicker. + + +getEndDate +---------- + +Arguments: None + +Returns the upper date limit on the datepicker. + + setStartDate ------------ diff --git a/js/bootstrap-datepicker.js b/js/bootstrap-datepicker.js index 65f5f0d..d86885f 100644 --- a/js/bootstrap-datepicker.js +++ b/js/bootstrap-datepicker.js @@ -638,7 +638,7 @@ }, getStartDate: function(){ - return this._utc_to_local(this.o.startDate); + return this.o.startDate; }, setStartDate: function(startDate){ @@ -649,7 +649,7 @@ }, getEndDate: function(){ - return this._utc_to_local(this.o.endDate); + return this.o.endDate; }, setEndDate: function(endDate){ diff --git a/tests/suites/methods.js b/tests/suites/methods.js index 572cdf2..4d74e01 100644 --- a/tests/suites/methods.js +++ b/tests/suites/methods.js @@ -92,6 +92,24 @@ test('setEndDate', function(){ strictEqual(returnedObject, this.dp, "is chainable"); }); +test('getStartDate', function(){ + var date_in = new Date(Date.UTC(2012, 3, 5)), + expected_date = date_in, + returnedObject = this.dp.setStartDate(date_in); + // ... + datesEqual(returnedObject.getStartDate(), expected_date); + strictEqual(returnedObject, this.dp, "is chainable"); +}); + +test('getEndDate', function(){ + var date_in = new Date(Date.UTC(2012, 3, 5)), + expected_date = date_in, + returnedObject = this.dp.setEndDate(date_in); + // ... + datesEqual(returnedObject.getEndDate(), expected_date); + strictEqual(returnedObject, this.dp, "is chainable"); +}); + test('setDaysOfWeekDisabled - String', function(){ var days_in = "0,6", expected_days = [0,6],