Skip to content

Commit 0a6e0be

Browse files
committed
Merge pull request #1033 from AnalyticalGraphicsInc/fixFromDate
Fix `JulianDate.fromDate` input validation.
2 parents c0b8247 + f1390d1 commit 0a6e0be

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

Source/Core/JulianDate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ define([
339339
* var julianDate = JulianDate.fromDate(date, TimeStandard.UTC);
340340
*/
341341
JulianDate.fromDate = function(date, timeStandard) {
342-
if (!defined(date) || date === null || isNaN(date.getTime())) {
342+
if (!(date instanceof Date) || isNaN(date.getTime())) {
343343
throw new DeveloperError('date must be a valid JavaScript Date.');
344344
}
345345

Specs/Core/JulianDateSpec.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,30 +214,12 @@ function(JulianDate,
214214
}).toThrow();
215215
});
216216

217-
it('Fail to construct from a null JavaScript Date', function() {
218-
expect(function() {
219-
return JulianDate.fromDate(null);
220-
}).toThrow();
221-
});
222-
223217
it('Fail to construct from an invalid JavaScript Date', function() {
224218
expect(function() {
225219
return JulianDate.fromDate(new Date(Date.parse('garbage')));
226220
}).toThrow();
227221
});
228222

229-
it('Fail to construct from a non-date JavaScript Date', function() {
230-
expect(function() {
231-
return JulianDate.fromDate(0);
232-
}).toThrow();
233-
});
234-
235-
it('Fail to construct from a JavaScript Date with null time standard', function() {
236-
expect(function() {
237-
return JulianDate.fromDate(new Date(), null);
238-
}).toThrow();
239-
});
240-
241223
it('Fail to construct from a JavaScript Date with invalid time standard', function() {
242224
expect(function() {
243225
return JulianDate.fromDate(new Date(), 'invalid');

0 commit comments

Comments
 (0)