Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fromJulian() should call toNumber() #6

Open
evilwombat opened this issue Dec 19, 2023 · 0 comments
Open

fromJulian() should call toNumber() #6

evilwombat opened this issue Dec 19, 2023 · 0 comments

Comments

@evilwombat
Copy link

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());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant