JulianDate loses millisecond precision

I’m trying to zoom the timeline to start/end milliseconds.
To do this I’m using JulianDate.fromDate(new Date(numMs)).
I’m finding that the JulianDate is losing precision and I need to maintain that precision.

Here is the example I’ve been working with:

Starting value: 1688170186280
new Date(ms).toISOString(): 2023-07-01T00:09:46.280Z
JulianDate.fromDate(…).toString(): 2023-07-01T00:09:46.27999999999883585Z

These resulting values are coming from console.logs and so the output is the toString() format.
Outputting the object shows an expected value for secondsOfDay.


Where is the strange precision coming from?
How can I fix the JulianDate to match the expected amount of milliseconds?

This is strongly related to the discussion around Inaccurate milliseconds value in JulianDate.toGregorianDate · Issue #10602 · CesiumGS/cesium · GitHub . If I remember correctly, the issue was not so much one of JulianDate, but rather that the JavaScript Date cannot represent fractional parts of milliseconds.