Skip to content

Commit e1b5ac7

Browse files
Correctly set microseconds when setting date and time
1 parent c9a9098 commit e1b5ac7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

jquery-ui-timepicker-addon.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@
15461546
tp_date.setMicroseconds(tp_inst.microsec);
15471547
} else {
15481548
tp_date = new Date(date.getTime());
1549+
tp_date.setMicroseconds(date.getMicroseconds());
15491550
}
15501551
if (tp_date.toString() == 'Invalid Date') {
15511552
tp_date = undefined;
@@ -1573,8 +1574,14 @@
15731574
}
15741575
}
15751576

1576-
var tp_inst = this._get(inst, 'timepicker'),
1577-
tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
1577+
var tp_inst = this._get(inst, 'timepicker');
1578+
var tp_date;
1579+
if (date instanceof Date) {
1580+
tp_date = new Date(date.getTime());
1581+
tp_date.setMicroseconds(date.getMicroseconds());
1582+
} else {
1583+
tp_date = date;
1584+
}
15781585

15791586
// This is important if you are using the timezone option, javascript's Date
15801587
// object will only return the timezone offset for the current locale, so we

0 commit comments

Comments
 (0)