Domanda

I'm trying to create a textbox that accepts mm/yy. For some reason this doesn't like dates beyond 2032. Can anyone tell me why not and what the solution is?

Update: Problem appears to be strictly a 2 digit year issue.

<input type="text" class="miniTextBox" id="${id}_Date" name="${id}_Date" maxlength="5"
 data-dojo-attach-point="indate"
 data-dojo-type="dijit/form/DateTextBox"  
 data-dojo-props="constraints:{fullYear: false, datePattern: 'MM/yy', max: '2099-12-31'},
 popupClass: 'dojox.widget.MonthAndYearlyCalendar'" 
 promptMessage="Example: 10/14" />

If it makes any difference, the following information may be helpful:

  • Uses Dojo 1.8
  • This is part of a widget template
  • There is a postCreate modification on this widget to set the fullYear constraint to false.
  • It does not use the standard popup calendar, and it doesn't matter if the date is entered by the popup or from the textbox.
  • the problem appears to be strictly a 2 digit year format issue - it works fine when the date format is changed to MM/yyyy and fullYear is true.
È stato utile?

Soluzione

In case anyone is still wondering, this is expected behavior. See documentation.

When two digit years are used, a century is chosen according to a sliding window of 80 years before and 20 years after present year, for both yy and yyyy patterns.

2033 was just outside that window in 2013 and 33 was interpreted as 1933.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top