BCE dates?

As far as I can tell, there is no way to put BCE or negative dates into the Cesium timeline. The clock will scrub backwards into BCE but if I try pulling the timeline back that far, it will crash the page and give me an invalid iso8601 error:

DeveloperError: Invalid ISO 8601 date.
Error
    at new t (http://localhost:8080/Build/Cesium/Cesium.js:417:6242)
    at Function.M.fromIso8601 (http://localhost:8080/Build/Cesium/Cesium.js:423:5193)
    at w._makeTics (http://localhost:8080/Build/Cesium/Cesium.js:464:12615)
    at w.zoomTo (http://localhost:8080/Build/Cesium/Cesium.js:464:10898)
    at w.updateFromClock (http://localhost:8080/Build/Cesium/Cesium.js:464:15527)
    at r.raiseEvent (http://localhost:8080/Build/Cesium/Cesium.js:417:22698)
    at l.tick (http://localhost:8080/Build/Cesium/Cesium.js:423:12017)
    at P.render (http://localhost:8080/Build/Cesium/Cesium.js:462:15594)
    at t (http://localhost:8080/Build/Cesium/Cesium.js:462:2645)

Are there any work arounds?

This looks like a bug in the _makTics function around line 379. Cesium internally uses JulianDate, which can go back to 4713 BCE but standard ISO8601 dates can not represent times before 0 BCE. The few lines of code I linked to should use JulianDate.toGregorianDate instead of creating an ISO8601 string. If you want to update the code, we’ll gladly take a pull request, I think it should be pretty straight forward.

If you need dates before 4713 BCE, I think it will still work, I’m not sure if there are any ramifications to negative Julian Day numbers in our code.

Thanks! I'm not sure this is a full fix because it's not splitting up the durations like the current function is doing but it works for my purposes. I went to line 379 and inserted:

if(startJulian.dayNumber<1721423.5){
         epochJulian = startJulian;
        }
        else if (duration > 315360000)...

1721423.5 is the first AD Julian Day Number so everything before that just sets epochJulian to startJulian.

Again, not ideal but it works for my purposes. I've never contributed to a large open source project before but let me know if this is worth submitting a pull request for. It'd be great if the next version of Cesium is able to deal with BCE dates out of the box.

Thanks so much for your help!

It never hurts to submit a pull-request when you fix a bug and/or edge-case. It’s what makes open-source work :slight_smile:

Just make sure to give a quick read of the contributing guide before creating your first pull-request to make sure it is good to go when the team reviews it.