summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Sanchez <julien.sanchez@lim.eu>2013-11-25 16:35:24 +0100
committerJulien Sanchez <julien.sanchez@lim.eu>2013-11-25 16:35:24 +0100
commiteeccc8248a7f575d2e4b9251e72a57febccf507c (patch)
tree998a0fd541f15fd21dbbc065f6f367a6d4d20ccb
parent11aaecbf7316fd2cf4f3097876278fc438ffc0d0 (diff)
downloadjQuery-Timepicker-Addon-eeccc8248a7f575d2e4b9251e72a57febccf507c.zip
jQuery-Timepicker-Addon-eeccc8248a7f575d2e4b9251e72a57febccf507c.tar.gz
jQuery-Timepicker-Addon-eeccc8248a7f575d2e4b9251e72a57febccf507c.tar.bz2
Fix failure when setting date as null
Otherwise, Timepicker is breaking Datepicker compatibility by not accepting null value.
-rw-r--r--src/jquery-ui-timepicker-addon.js2
-rw-r--r--test/SpecRunner.html5
-rw-r--r--test/jquery-ui-timepicker-addon_spec.js15
3 files changed, 20 insertions, 2 deletions
diff --git a/src/jquery-ui-timepicker-addon.js b/src/jquery-ui-timepicker-addon.js
index 1061296..71ec2cd 100644
--- a/src/jquery-ui-timepicker-addon.js
+++ b/src/jquery-ui-timepicker-addon.js
@@ -1611,7 +1611,7 @@
// object will only return the timezone offset for the current locale, so we
// adjust it accordingly. If not using timezone option this won't matter..
// If a timezone is different in tp, keep the timezone as is
- if (tp_inst) {
+ if (tp_inst && tp_date) {
// look out for DST if tz wasn't specified
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
diff --git a/test/SpecRunner.html b/test/SpecRunner.html
index 5c76f6f..9793cc5 100644
--- a/test/SpecRunner.html
+++ b/test/SpecRunner.html
@@ -7,6 +7,11 @@
<link rel="shortcut icon" type="image/png" href="../lib/jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="../lib/jasmine-1.3.1/jasmine.css">
+ <style>
+ .ui-datepicker {
+ display: none;
+ }
+ </style>
<script type="text/javascript" src="../lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="../lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js"></script>
diff --git a/test/jquery-ui-timepicker-addon_spec.js b/test/jquery-ui-timepicker-addon_spec.js
index c0cdc7b..7da1ecf 100644
--- a/test/jquery-ui-timepicker-addon_spec.js
+++ b/test/jquery-ui-timepicker-addon_spec.js
@@ -648,4 +648,17 @@ describe('datetimepicker', function() {
});
});
});
-}); \ No newline at end of file
+
+ describe('methods', function() {
+ describe('setDate', function() {
+ it('should accept null as date', function() {
+ var $input = affix('input').datetimepicker();
+ $input.datetimepicker('setDate', '2013-11-25 15:30:25');
+
+ $input.datetimepicker('setDate', null);
+
+ expect($input.datetimepicker('getDate')).toBeNull();
+ });
+ });
+ });
+});