Skip to content

default hour and minute have no effect #102

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

Closed
midnightmonster opened this issue Feb 2, 2011 · 5 comments
Closed

default hour and minute have no effect #102

midnightmonster opened this issue Feb 2, 2011 · 5 comments

Comments

@midnightmonster
Copy link

var dd = new Date();
dd.setDate(date.getDate()+7);
$('#thing').datetimepicker({
  defaultDate:dd,
  hour:dd.getHours(),
  minute:dd.getHours()
});

Expected result:
When I focus #thing, the date portion has the date 1 week from now selected, and the time picker has the current time.

Actual result:
Date portion is set correctly, time is set to midnight.

It seems that right at the beginning of _newInst:

_newInst: function($input, o) {
    var tp_inst = new Timepicker(),
        inlineSettings = {};

    tp_inst.hour = tp_inst._defaults.hour;
    tp_inst.minute = tp_inst._defaults.minute;
    tp_inst.second = tp_inst._defaults.second;

The instance time is set from the defaults before the defaults have been initialized with the settings from o.

The best solution would be if I didn't have to set hour and minute separately at all, but the timepicker would get them from the defaultDate.

@wastedspace
Copy link

I have the same issue. No update yet?

@boris-glumpler
Copy link

Changing this.hour (line 461), this.minute (line 475) and this.second (line 488) to o.hour, o.minute and o.second respectively seems to resolve the issue.

@wastedspace
Copy link

Perfect! Thanks :)

@rayfranco
Copy link

I did a pull request to fix this, you can get the update here : RayFranco/jQuery-Timepicker-Addon@4db3c854a313d77b3577e284519b6f20c85ba98e

@patrickdavey
Copy link

For anyone else copying and pasting this ;) Watch out for the two getHours() above...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants