Skip to content

Commit f5ee24c

Browse files
committed
Datepicker: Zero-pad years 0-999 to four digits
1 parent ffcc7f2 commit f5ee24c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ui/widgets/datepicker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,7 @@ $.extend( Datepicker.prototype, {
14191419
dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
14201420
monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
14211421
monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
1422+
year,
14221423

14231424
// Check whether a format character is doubled
14241425
lookAhead = function( match ) {
@@ -1474,8 +1475,10 @@ $.extend( Datepicker.prototype, {
14741475
output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
14751476
break;
14761477
case "y":
1477-
output += ( lookAhead( "y" ) ? date.getFullYear() :
1478-
( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
1478+
year = date.getFullYear();
1479+
output += ( lookAhead( "y" ) ?
1480+
( year >= 0 && year < 1000 ? ( year < 10 ? "000" : year < 100 ? "00" : "0" ) : "" ) + year :
1481+
( year % 100 < 10 ? "0" : "" ) + year % 100 );
14791482
break;
14801483
case "@":
14811484
output += date.getTime();

0 commit comments

Comments
 (0)