diff --git a/Source/Core/JulianDate.js b/Source/Core/JulianDate.js index 4f0759580026..390ff91b975f 100644 --- a/Source/Core/JulianDate.js +++ b/Source/Core/JulianDate.js @@ -122,7 +122,7 @@ define([ var a = ((month - 14) / 12) | 0; var b = year + 4800 + a; - var dayNumber = (((1461 * b) / 4) | 0) + (((367 * (month - 2 - 12 * a)) / 12) | 0) - (((3 * ((b + 100) / 100)) / 4) | 0) + day - 32075; + var dayNumber = (((1461 * b) / 4) | 0) + (((367 * (month - 2 - 12 * a)) / 12) | 0) - (((3 * (((b + 100) / 100) | 0)) / 4) | 0) + day - 32075; // JulianDates are noon-based hour = hour - 12; diff --git a/Specs/Core/JulianDateSpec.js b/Specs/Core/JulianDateSpec.js index 4fb6a2ad6cdb..933b3485ec50 100644 --- a/Specs/Core/JulianDateSpec.js +++ b/Specs/Core/JulianDateSpec.js @@ -146,6 +146,13 @@ defineSuite([ expect(julianDate.secondsOfDay).toEqual(34); }); + it('Construct a date from a JavaScript Date (5)', function() { + var jsDate = new Date('11/17/2039 12:00:00 AM UTC'); + var julianDate = JulianDate.fromDate(jsDate); + expect(julianDate.dayNumber).toEqual(2466109); + expect(julianDate.secondsOfDay).toEqual(43236); + }); + it('Fail to construct from an undefined JavaScript Date', function() { expect(function() { return JulianDate.fromDate(undefined);