Skip to content

Correctly set microseconds when setting date and time #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down