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

Function createDateParser

lib/test/angular/1.5.0/angular.js:22763–22811  ·  view source on GitHub ↗
(regexp, mapping)

Source from the content-addressed store, hash-verified

22761}
22762
22763function createDateParser(regexp, mapping) {
22764 return function(iso, date) {
22765 var parts, map;
22766
22767 if (isDate(iso)) {
22768 return iso;
22769 }
22770
22771 if (isString(iso)) {
22772 // When a date is JSON'ified to wraps itself inside of an extra
22773 // set of double quotes. This makes the date parsing code unable
22774 // to match the date string and parse it as a date.
22775 if (iso.charAt(0) == '"' && iso.charAt(iso.length - 1) == '"') {
22776 iso = iso.substring(1, iso.length - 1);
22777 }
22778 if (ISO_DATE_REGEXP.test(iso)) {
22779 return new Date(iso);
22780 }
22781 regexp.lastIndex = 0;
22782 parts = regexp.exec(iso);
22783
22784 if (parts) {
22785 parts.shift();
22786 if (date) {
22787 map = {
22788 yyyy: date.getFullYear(),
22789 MM: date.getMonth() + 1,
22790 dd: date.getDate(),
22791 HH: date.getHours(),
22792 mm: date.getMinutes(),
22793 ss: date.getSeconds(),
22794 sss: date.getMilliseconds() / 1000
22795 };
22796 } else {
22797 map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 };
22798 }
22799
22800 forEach(parts, function(part, index) {
22801 if (index < mapping.length) {
22802 map[mapping[index]] = +part;
22803 }
22804 });
22805 return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm, map.ss || 0, map.sss * 1000 || 0);
22806 }
22807 }
22808
22809 return NaN;
22810 };
22811}
22812
22813function createDateInputType(type, regexp, parseDate, format) {
22814 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