angular-ui-bootstrap
Advanced tools
Comparing version 2.3.2 to 2.4.0
{ | ||
"author": "https://github.com/angular-ui/bootstrap/graphs/contributors", | ||
"name": "angular-ui-bootstrap", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"homepage": "http://angular-ui.github.io/bootstrap/", | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
angular.module('ui.bootstrap.dateparser', []) | ||
.service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', function($log, $locale, dateFilter, orderByFilter) { | ||
.service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', 'filterFilter', function($log, $locale, dateFilter, orderByFilter, filterFilter) { | ||
// Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js | ||
@@ -246,2 +246,19 @@ var SPECIAL_CHARACTERS_REGEXP = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; | ||
function getFormatCodeToRegex(key) { | ||
return filterFilter(formatCodeToRegex, {key: key}, true)[0]; | ||
} | ||
this.getParser = function (key) { | ||
var f = getFormatCodeToRegex(key); | ||
return f && f.apply || null; | ||
}; | ||
this.overrideParser = function (key, parser) { | ||
var f = getFormatCodeToRegex(key); | ||
if (f && angular.isFunction(parser)) { | ||
this.parsers = {}; | ||
f.apply = parser; | ||
} | ||
}.bind(this); | ||
function createParser(format) { | ||
@@ -248,0 +265,0 @@ var map = [], regex = format.split(''); |
@@ -794,2 +794,26 @@ describe('date parser', function() { | ||
}); | ||
describe('overrideParser', function() { | ||
var twoDigitYearParser = function (value) { | ||
this.year = +value + (+value > 30 ? 1900 : 2000); | ||
}; | ||
it('should get the current parser', function() { | ||
expect(dateParser.getParser('yy')).toBeTruthy(); | ||
}); | ||
it('should override the parser', function() { | ||
dateParser.overrideParser('yy', twoDigitYearParser); | ||
expect(dateParser.parse('68', 'yy').getFullYear()).toEqual(1968); | ||
expect(dateParser.parse('67', 'yy').getFullYear()).toEqual(1967); | ||
expect(dateParser.parse('31', 'yy').getFullYear()).toEqual(1931); | ||
expect(dateParser.parse('30', 'yy').getFullYear()).toEqual(2030); | ||
}); | ||
it('should clear cached parsers', function() { | ||
expect(dateParser.parse('68', 'yy').getFullYear()).toEqual(2068); | ||
dateParser.overrideParser('yy', twoDigitYearParser); | ||
expect(dateParser.parse('68', 'yy').getFullYear()).toEqual(1968); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1847200
36785