MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / createDateParser

Function createDateParser

lib/test/angular/1.6.7/angular.js:25337–25385  ·  view source on GitHub ↗
(regexp, mapping)

Source from the content-addressed store, hash-verified

25335}
25336
25337function createDateParser(regexp, mapping) {
25338 return function(iso, date) {
25339 var parts, map;
25340
25341 if (isDate(iso)) {
25342 return iso;
25343 }
25344
25345 if (isString(iso)) {
25346 // When a date is JSON'ified to wraps itself inside of an extra
25347 // set of double quotes. This makes the date parsing code unable
25348 // to match the date string and parse it as a date.
25349 if (iso.charAt(0) === '"' && iso.charAt(iso.length - 1) === '"') {
25350 iso = iso.substring(1, iso.length - 1);
25351 }
25352 if (ISO_DATE_REGEXP.test(iso)) {
25353 return new Date(iso);
25354 }
25355 regexp.lastIndex = 0;
25356 parts = regexp.exec(iso);
25357
25358 if (parts) {
25359 parts.shift();
25360 if (date) {
25361 map = {
25362 yyyy: date.getFullYear(),
25363 MM: date.getMonth() + 1,
25364 dd: date.getDate(),
25365 HH: date.getHours(),
25366 mm: date.getMinutes(),
25367 ss: date.getSeconds(),
25368 sss: date.getMilliseconds() / 1000
25369 };
25370 } else {
25371 map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 };
25372 }
25373
25374 forEach(parts, function(part, index) {
25375 if (index < mapping.length) {
25376 map[mapping[index]] = +part;
25377 }
25378 });
25379 return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm, map.ss || 0, map.sss * 1000 || 0);
25380 }
25381 }
25382
25383 return NaN;
25384 };
25385}
25386
25387function createDateInputType(type, regexp, parseDate, format) {
25388 return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) {

Callers 1

angular.jsFile · 0.70

Calls 3

isDateFunction · 0.70
isStringFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected