trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

Feature request: additional option for timeOnly to show date, too. #633

Closed JohnArcher closed 10 years ago

JohnArcher commented 11 years ago

Hi there!

I am not sure whether this is already possible somehow, but I want to achieve that the input field can also show the current/default date, although set the timeOnly option to true. I guess I could also use the altField stuff, which if I understand it correctly I can split time and date into two input fields? But my projects require that I have one input fields which shows both date and time but I can only adjust the time.

I already figured out how to alter you code to achieve that but before I pull request that I want to make sure that this is ok and there is no other way to achieve that. Basically it is that (in _updateDateTime() where timeOnlyShowDate is my new option):

if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) {
    formattedDateTime = this.formattedTime;
} else if ((this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) || (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === true)) {
    formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
}

What do you think?

Regards

JohnArcher commented 11 years ago

Any opionions on that, @trentrichardson ? Thanks a lot!

JohnArcher commented 10 years ago

I would be very happy and thankful, if you could comment that, @trentrichardson . Thanks!

trentrichardson commented 10 years ago

@JohnArcher Sorry for the delay, I completely missed this post. That probably wouldn't be a bad option to integrate in. Not sure if that would be the only place changes would need to be made, but with any luck that would cover it.

trentrichardson commented 10 years ago

@JohnArcher I applied your changes and it appears to work fine. It is in the dev branch.

JohnArcher commented 10 years ago

Hey, cool, thanks a lot!

Do you think, the name of the option is ok (as English is not my native language)?

Hm, maybe another way would be to extend pickerTimeFormat or the timeformat respectively so you could also use the datepicker-mmddyy-stuff there, too? Just a quick thought, don't know, whether this is easy to implement and convenient ...

trentrichardson commented 10 years ago

They way you had it is probably best. I try to not do any "date" related work and leave that to datepicker. If you knew what the date was in advance you can always use the literal syntax inside the timeformat like so: "'2014-03-05' HH:mm:ss". Anything in the timeFormat inside of single quotes should be bypassed and treated as literal text. I think the option name explains what it is trying to do pretty clear, so it is good.

JohnArcher commented 10 years ago

Ok, great, thanks a lot for the hints (I think it is good that you leave the date stuff out) and your work.

Cheers!