Opened 13 years ago

Closed 10 years ago

#6123 closed bug (notabug)

Datepicker: strange interaction with yearRange and defaultDate

Reported by: fokeyjoe Owned by:
Priority: minor Milestone: 1.11.0
Component: ui.datepicker Version: 1.8.4
Keywords: yearRange defaultDate Cc:
Blocked by: Blocking:


I'm trying to get the datepicker to give a list with the yearRange c-100:c-18 (employee dob's, and could be outside the range so min/maxDate not relevant). By default it shows 1910 (I guess because the latest year), but I want it to show 1992 by default, but I can't get it to, and I think it might be a bug due to the base date chosen when the current year isn't available. Initially, I started with:

  dateFormat : 'dd-mm-yy',
  gotoCurrent: true,
  changeYear: true,
  yearRange: "c-100:c-18"});

I tried to work around it with:

var defDate = new Date();
$(document).ready(function () {
        dateFormat : 'dd-mm-yy',
        gotoCurrent: true,
        changeYear: true,
        defaultDate: defDate,
        yearRange: "c-100:c-18"

But this workaround shows a date of 1892, and the year list changes to go down. If I replace -18 in defDate with +82, I get 1992 as the default, but the list of years is then incorrect. The workaround I can go with is the latter with a yearRange of c-100:c+0, then the defaultDate seems to work properly.

Change History (3)

comment:1 Changed 13 years ago by fokeyjoe

Sorry.. think I confused myself, my last workaround does exactly what I want, and I can see why, yearRange is relative to defaultDate. I guess it was just the way it switched to a different date when yearRange was not inclusive of the defaultDate. I'm not sure if that should be fixed or not - maybe just a note in the docs?

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

Milestone: TBD1.11.0

comment:3 Changed 10 years ago by mikesherov

Resolution: notabug
Status: newclosed
Note: See TracTickets for help on using tickets.