(specifier, Z)
| 16179 | } |
| 16180 | |
| 16181 | function newParse(specifier, Z) { |
| 16182 | return function(string) { |
| 16183 | var d = newDate(1900, undefined, 1), |
| 16184 | i = parseSpecifier(d, specifier, string += "", 0), |
| 16185 | week, day; |
| 16186 | if (i != string.length) return null; |
| 16187 | |
| 16188 | // If a UNIX timestamp is specified, return it. |
| 16189 | if ("Q" in d) return new Date(d.Q); |
| 16190 | if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); |
| 16191 | |
| 16192 | // If this is utcParse, never use the local timezone. |
| 16193 | if (Z && !("Z" in d)) d.Z = 0; |
| 16194 | |
| 16195 | // The am-pm flag is 0 for AM, and 1 for PM. |
| 16196 | if ("p" in d) d.H = d.H % 12 + d.p * 12; |
| 16197 | |
| 16198 | // If the month was not specified, inherit from the quarter. |
| 16199 | if (d.m === undefined) d.m = "q" in d ? d.q : 0; |
| 16200 | |
| 16201 | // Convert day-of-week and week-of-year to day-of-year. |
| 16202 | if ("V" in d) { |
| 16203 | if (d.V < 1 || d.V > 53) return null; |
| 16204 | if (!("w" in d)) d.w = 1; |
| 16205 | if ("Z" in d) { |
| 16206 | week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); |
| 16207 | week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); |
| 16208 | week = utcDay.offset(week, (d.V - 1) * 7); |
| 16209 | d.y = week.getUTCFullYear(); |
| 16210 | d.m = week.getUTCMonth(); |
| 16211 | d.d = week.getUTCDate() + (d.w + 6) % 7; |
| 16212 | } else { |
| 16213 | week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); |
| 16214 | week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week); |
| 16215 | week = timeDay.offset(week, (d.V - 1) * 7); |
| 16216 | d.y = week.getFullYear(); |
| 16217 | d.m = week.getMonth(); |
| 16218 | d.d = week.getDate() + (d.w + 6) % 7; |
| 16219 | } |
| 16220 | } else if ("W" in d || "U" in d) { |
| 16221 | if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; |
| 16222 | day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); |
| 16223 | d.m = 0; |
| 16224 | d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; |
| 16225 | } |
| 16226 | |
| 16227 | // If a time zone is specified, all fields are interpreted as UTC and then |
| 16228 | // offset according to the specified time zone. |
| 16229 | if ("Z" in d) { |
| 16230 | d.H += d.Z / 100 | 0; |
| 16231 | d.M += d.Z % 100; |
| 16232 | return utcDate(d); |
| 16233 | } |
| 16234 | |
| 16235 | // Otherwise, all fields are in local time. |
| 16236 | return localDate(d); |
| 16237 | }; |
| 16238 | } |
no test coverage detected