From e1b5ac77d22bb7b75292de076abe74fced7fb6db Mon Sep 17 00:00:00 2001 From: Kasun Chathuranga Date: Tue, 14 May 2013 22:27:29 +0530 Subject: Correctly set microseconds when setting date and time --- jquery-ui-timepicker-addon.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 12b7f77..e5da424 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -1546,6 +1546,7 @@ tp_date.setMicroseconds(tp_inst.microsec); } else { tp_date = new Date(date.getTime()); + tp_date.setMicroseconds(date.getMicroseconds()); } if (tp_date.toString() == 'Invalid Date') { tp_date = undefined; @@ -1573,8 +1574,14 @@ } } - var tp_inst = this._get(inst, 'timepicker'), - tp_date = (date instanceof Date) ? new Date(date.getTime()) : date; + var tp_inst = this._get(inst, 'timepicker'); + var tp_date; + if (date instanceof Date) { + tp_date = new Date(date.getTime()); + tp_date.setMicroseconds(date.getMicroseconds()); + } else { + tp_date = date; + } // This is important if you are using the timezone option, javascript's Date // object will only return the timezone offset for the current locale, so we -- cgit v1.1