(regexp, mapping)
| 19999 | } |
| 20000 | |
| 20001 | function createDateParser(regexp, mapping) { |
| 20002 | return function(iso, date) { |
| 20003 | var parts, map; |
| 20004 | |
| 20005 | if (isDate(iso)) { |
| 20006 | return iso; |
| 20007 | } |
| 20008 | |
| 20009 | if (isString(iso)) { |
| 20010 | // When a date is JSON'ified to wraps itself inside of an extra |
| 20011 | // set of double quotes. This makes the date parsing code unable |
| 20012 | // to match the date string and parse it as a date. |
| 20013 | if (iso.charAt(0) == '"' && iso.charAt(iso.length - 1) == '"') { |
| 20014 | iso = iso.substring(1, iso.length - 1); |
| 20015 | } |
| 20016 | if (ISO_DATE_REGEXP.test(iso)) { |
| 20017 | return new Date(iso); |
| 20018 | } |
| 20019 | regexp.lastIndex = 0; |
| 20020 | parts = regexp.exec(iso); |
| 20021 | |
| 20022 | if (parts) { |
| 20023 | parts.shift(); |
| 20024 | if (date) { |
| 20025 | map = { |
| 20026 | yyyy: date.getFullYear(), |
| 20027 | MM: date.getMonth() + 1, |
| 20028 | dd: date.getDate(), |
| 20029 | HH: date.getHours(), |
| 20030 | mm: date.getMinutes(), |
| 20031 | ss: date.getSeconds(), |
| 20032 | sss: date.getMilliseconds() / 1000 |
| 20033 | }; |
| 20034 | } else { |
| 20035 | map = { yyyy: 1970, MM: 1, dd: 1, HH: 0, mm: 0, ss: 0, sss: 0 }; |
| 20036 | } |
| 20037 | |
| 20038 | forEach(parts, function(part, index) { |
| 20039 | if (index < mapping.length) { |
| 20040 | map[mapping[index]] = +part; |
| 20041 | } |
| 20042 | }); |
| 20043 | return new Date(map.yyyy, map.MM - 1, map.dd, map.HH, map.mm, map.ss || 0, map.sss * 1000 || 0); |
| 20044 | } |
| 20045 | } |
| 20046 | |
| 20047 | return NaN; |
| 20048 | }; |
| 20049 | } |
| 20050 | |
| 20051 | function createDateInputType(type, regexp, parseDate, format) { |
| 20052 | return function dynamicDateInputType(scope, element, attr, ctrl, $sniffer, $browser, $filter) { |
no test coverage detected