Skip to content

altFormat doesn't work clicking "Done" #143

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

Open
twinklebob opened this issue May 4, 2011 · 2 comments
Open

altFormat doesn't work clicking "Done" #143

twinklebob opened this issue May 4, 2011 · 2 comments

Comments

@twinklebob
Copy link

Apologies if this has been recorded before.

I'm using version 0.9.3.

I want to display a pretty format to the user:
dateFormat: 'DD, d MM yy', timeFormat: 'hh:mm',

And store an equivalent timestamp in a hidden field (for processing), so have used:
altFormat: '@'

This seems to work if I select a date and hit 'Esc'. But if I select a date and click "Done" the pretty format is put into the hidden field.

Why? How can I enforce the use of the AltFormat?

@NicolasIMBERT
Copy link

Sorry I posted #226 issue on same subjects.
#226

@MIvanIsten
Copy link

Use

altFieldTimeOnly: false

And apply this patch to v1.0.0

Index: jquery-ui-timepicker-addon.js
===================================================================
--- jquery-ui-timepicker-addon.js   (revision xxxx)
+++ jquery-ui-timepicker-addon.js   (working copy)
@@ -870,6 +870,9 @@
        if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
            return;

+       var altFormat = $.datepicker._get(dp_inst, 'altFormat') || $.datepicker._get(dp_inst, 'dateFormat');
+       var altFormattedDateTime = $.datepicker.formatDate(altFormat, new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay, this.hour, this.minute, this.second, this.millisec), formatCfg);
+
        if (this._defaults.timeOnly === true) {
            formattedDateTime = this.formattedTime;
        } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
@@ -884,7 +887,7 @@
            this.$altInput.val(this.formattedTime);
            this.$input.val(this.formattedDate);
        } else if(this.$altInput) {
-           this.$altInput.val(formattedDateTime);
+           this.$altInput.val(altFormattedDateTime);
            this.$input.val(formattedDateTime);
        } else {
            this.$input.val(formattedDateTime);

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

3 participants