SunCalc
SunCalc copied to clipboard
fromJulian() should call toNumber()
Long story short, I'm ending up with Moments backed by a floating point type (rather than an int type) when running on sim. This leads to truly bizarre results, arising from what I believe is epoch times being stored in single-precision floats, then experiencing loss of precision due to the magnitude of the values involved.
See https://forums.garmin.com/developer/connect-iq/f/discussion/354859/monkey-business-in-data-types-used-by-moment-internals.
Seeing this issue on sim only, while Moments on real HW seem to cast-to-int in their constructor.
Workaround:
function fromJulian(j) {
return new Time.Moment(((j + 0.5 - J1970) * DAYS).toNumber());
}