MCPcopy Create free account
hub / github.com/cujojs/poly / checkIsoCompat

Function checkIsoCompat

date.js:134–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132 }
133
134 function checkIsoCompat () {
135 // fix Date constructor
136
137 var newDate = (function () {
138 // Replacement Date constructor
139 return function Date (y, m, d, h, mn, s, ms) {
140 var len, result;
141
142 // Date called as function, not constructor
143 if (!(this instanceof newDate)) return origDate.apply(this, arguments);
144
145 len = arguments.length;
146
147 if (len === 0) {
148 result = new origDate();
149 }
150 else if (len === 1) {
151 result = new origDate(base.isString(y) ? newDate.parse(y) : y);
152 }
153 else {
154 result = new origDate(y, m, d == undef ? 1 : d, h || 0, mn || 0, s || 0, ms || 0);
155 }
156
157 result.constructor = newDate;
158
159 return result;
160 };
161 }());
162
163 if (!isoCompat()) {
164
165 newDate.now = origDate.now;
166 newDate.UTC = origDate.UTC;
167 newDate.prototype = origProto;
168 newDate.prototype.constructor = newDate;
169
170 newDate.parse = function parse (str) {
171 var result;
172
173 // check for iso date
174 result = isoParse('' + str);
175
176 if (isInvalidDate(result)) {
177 // try original parse()
178 result = origParse(str);
179 }
180
181 return result;
182 };
183
184 // Unfortunate. See cujojs/poly#11
185 // Copy any owned props that may have been previously added to
186 // the Date constructor by 3rd party libs.
187 copyPropsSafely(newDate, origDate);
188
189 Date = newDate;
190 }
191 else if (Date != origDate) {

Callers 1

date.jsFile · 0.85

Calls 3

isoParseFunction · 0.85
isInvalidDateFunction · 0.85
copyPropsSafelyFunction · 0.85

Tested by

no test coverage detected