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

Millisecond timestamps #60

Closed
silverwind opened this issue Dec 3, 2019 · 4 comments
Closed

Millisecond timestamps #60

silverwind opened this issue Dec 3, 2019 · 4 comments
Labels
docs Improvements or additions to documentation

Comments

@silverwind
Copy link
Contributor

In JS, one usually works with Unix timestamps in milliseconds format and I'm wondering if it would not be wiser for this module to expect them in this format too. I could see it being useful especially for scientific topics that require very high precision.

> (new Date()).getTime()
1575354886419

If I pass that to uPlot, it renders as year 51890 😉

@leeoniya
Copy link
Owner

leeoniya commented Dec 3, 2019

i was on the fence about this for a while. on one hand milli is the native format, on the other hand most timescales that humans deal with are better represented by at least a second.

if i need millisecond precision in a plot, there's a 100% chance that i don't need the hour, day, date, month or year - i usually dont even need the minute. the values cease to be "time" in any meaningful sense and all the complexity that goes along with calendar-based time, like timezones and dst - i might as well just use a numeric time: false x axis from some declared initial offset.

storage of regular, non-milli timestamps is also higher density and doesnt require repetition of the 000 appendage.

if you need sub-second precision on a true timescale, you can always use floats:

1575354886.419

at least that's my thinking.

@silverwind
Copy link
Contributor Author

It's not something I personally require (I only had a bug because of it as I was converting from ISO format which gives the native milliseconds). I guess seconds precision is enough for most people and if floats work, that is a valid alternative. Maybe just document it at https://github.com/leeoniya/uPlot#data-format that precision is expected in seconds and floats are accepted.

@leeoniya
Copy link
Owner

leeoniya commented Dec 3, 2019

done.

@silverwind
Copy link
Contributor Author

Thanks!

@leeoniya leeoniya added the docs Improvements or additions to documentation label Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants