diff --git a/src/dateparser/dateparser.js b/src/dateparser/dateparser.js index 07df3cfa0a..2dbed30b1d 100644 --- a/src/dateparser/dateparser.js +++ b/src/dateparser/dateparser.js @@ -27,7 +27,7 @@ angular.module('ui.bootstrap.dateparser', []) { key: 'yy', regex: '\\d{2}', - apply: function(value) { this.year = +value + 2000; }, + apply: function(value) { value = +value; this.year = value < 69 ? value + 2000 : value + 1900; }, formatter: function(date) { var _date = new Date(); _date.setFullYear(Math.abs(date.getFullYear())); diff --git a/src/dateparser/test/dateparser.spec.js b/src/dateparser/test/dateparser.spec.js index 60ae8e1391..8b96a7c77a 100644 --- a/src/dateparser/test/dateparser.spec.js +++ b/src/dateparser/test/dateparser.spec.js @@ -282,11 +282,16 @@ describe('date parser', function() { it('should work correctly for `yy`', function() { expectParse('17.11.13', 'dd.MM.yy', new Date(2013, 10, 17, 0)); expectParse('02-05-11', 'dd-MM-yy', new Date(2011, 4, 2, 0)); - expectParse('02/05/80', 'MM/dd/yy', new Date(2080, 1, 5, 0)); + expectParse('02/05/80', 'MM/dd/yy', new Date(1980, 1, 5, 0)); expectParse('55/02/05', 'yy/MM/dd', new Date(2055, 1, 5, 0)); expectParse('11-08-13', 'dd-MM-yy', new Date(2013, 7, 11, 0)); }); + it('should use `68` as the pivot year for `yy`', function() { + expectParse('17.11.68', 'dd.MM.yy', new Date(2068, 10, 17, 0)); + expectParse('17.11.69', 'dd.MM.yy', new Date(1969, 10, 17, 0)); + }); + it('should work correctly for `y`', function() { expectParse('17.11.2013', 'dd.MM.y', new Date(2013, 10, 17, 0)); expectParse('31.12.2013', 'dd.MM.y', new Date(2013, 11, 31, 0));