From db71119edbebfd38a7a863ca8c49e99b3df0223f Mon Sep 17 00:00:00 2001 From: Pedro Goes Date: Mon, 9 Jun 2014 16:44:51 +0100 Subject: [PATCH] startDate priority override --- jquery.datetimepicker.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index 279fbf1..15bd427 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -1229,16 +1229,23 @@ datetimepicker.setOptions(options); function getCurrentValue(){ - var ct = options.value?options.value:(input&&input.val&&input.val())?input.val():''; - - if( ct && _xdsoft_datetime.isValidDate(ct = Date.parseDate(ct, options.format)) ) { + + var ct = false; + + if (options.startDate instanceof Date && !isNaN(options.startDate.valueOf())) { + ct = options.startDate; + } else if (!ct && options.startDate!==false) { + ct = _xdsoft_datetime.strToDateTime(options.startDate); + } else if (!ct) { + ct = options.value?options.value:(input&&input.val&&input.val())?input.val():''; + ct = Date.parseDate(ct, options.format); + } + + if ( ct && _xdsoft_datetime.isValidDate(ct) ) { datetimepicker.data('changed',true); - }else - ct = ''; - - if( !ct && options.startDate!==false ){ - ct = _xdsoft_datetime.strToDateTime(options.startDate); - } + } else { + ct = ''; + } return ct?ct:0; }