Opened 12 years ago

Closed 12 years ago

Last modified 7 years ago

#7759 closed bug (notabug)

DateFormat without year (e.g. "d M") results in a corrupt datepicker

Reported by: saskovic Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.datepicker Version: 1.8.16
Keywords: Cc:
Blocked by: Blocking:

Description

Setting:

$this.datepicker( "option", "dateFormat", 'd MM' );
$this.datepicker('setDate', new Date()); // Today is 3 October 2011

Result: (FAIL)

  • 3 January 2011
  • Datepicker is not clickable


Setting:

$this.datepicker( "option", "dateFormat", 'MM' );
$this.datepicker('setDate', new Date()); // Today is 3 October 2011

Result: (FAIL)

  • October
  • Datepicker is not clickable


Setting:

$this.datepicker( "option", "dateFormat", 'd MM y' );
$this.datepicker('setDate', new Date()); // Today is 3 October 2011

Result: (SUCCESS)

  • 3 October 11
  • Datepicker is clickable

Change History (10)

comment:1 Changed 12 years ago by Scott González

Resolution: invalid
Status: newclosed

Datepicker is only designed to pick a full date.

comment:2 Changed 11 years ago by Scott González

#8151 is a duplicate of this ticket.

comment:3 Changed 11 years ago by nfm

Sorry for the dupe.

I disagree with the resolution.

I was under the impression that dateFormat was to control the visible output format. Given that the user selects a date with year (regardless of what dateFormat is set to), I'd expect that dateFormat be applied to the selected date.

In additional, when dateFormat doesn't include the year, getDate returns a different value to what gets set in altField.

The user selects a full date, but the year is discarded, and there's no way to retrieve the correct date programmatically. This shouldn't be the case, regardless of whether you're choosing to output the year in dateFormat or not.

comment:4 Changed 11 years ago by Scott González

The text field is the canonical data source. You can't not have a year.

comment:5 Changed 11 years ago by Scott González

#8510 is a duplicate of this ticket.

comment:6 Changed 11 years ago by Scott González

#8546 is a duplicate of this ticket.

comment:7 Changed 11 years ago by simon.sprankel

Sorry for the duplicate. But the number of duplicates show how important this issue is for many people. Why don't you save the date information in a data-* attribute and use the input field only for showing the date in the selected format?

comment:8 Changed 11 years ago by Scott González

Because that's not how any of our input-based widgets work. The input itself is the canonical data source. If you don't want it to be, then use a different trigger with an alt field or just create an inline datepicker and manage the showing/hiding yourself. If you need help, please use the forums.

comment:9 Changed 10 years ago by Scott González

#9454 is a duplicate of this ticket.

comment:10 Changed 7 years ago by Scott González

#14918 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.