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
Julian Day support missing #1276
Comments
The big problem with such support is that you do not need to go far into the future (or past) before the numbers become bigger than Javascript can handle, you then need an arbitrary-precision arithmetic library. Javascript's Date object is also limited to 100,000,000 days either side of 1 Jan 1970. So it is fine so long as you are doing calculations into the near future or near past. Other problems happen when you start using moment durations and addition/subtraction routines as these perform calculations on estimates that are of little or no use when performing astronomical calculations. I came across these exact problems when I tried to use moment as a base for such calculations, this resulted in me creating a library from scratch which is not based on Javascript's date object. This is not a fault of moment, so to speak, but moment would need to discard the use of the Date object and handle arbitrary-precision arithmetic. The library that I am working on for such calculations is AstroDate. Maybe some day moment will be able to use such a library as a replacement to Date, but it will be a while. Until then, the strength of moment is its date parsing and formatting abilities, and its ability to perform humanised approximations. |
According to the wikipedia article 1 Jan 2013, is around 2M days. I think JavaScript can handle numbers around 2M, it uses 64 bit floats (I guess), so 15 digits are a given. Maybe for seconds .. not that good :) I guess a code that handles JD can be implemented, and then arbitrary precision numbers can be plugged in later, if users really need it. |
For support of accurate Julian Dates (Julian Day Number + time as a fraction of day), you require a number to 9 decimal places (for millisecond support). 15 significant figures is the maximum to convert from a Javascript number to arbitary-precision. This means a min and max integer part of
Which when round tripped it gives Whereas with 9 dp Good job they didn't use So this drop in accuracy would allow you to convert from a Javascript number to arbitrary-precision, but you have already sacrificed accuracy in doing so. |
Closing this for now. Can be implemented using #1454 (in the future), the accuracy problem is a real one -- I guess using 2 numbers (one for days, another for milliseconds) would do the trick. |
Okay, thanks! |
Any updates on this? |
I would have used this feature if it existed today. |
+1 |
+1 useful for astronomical purposes |
old ticket, but is it implemented? |
I think Moment.js is missing a method to convert a datetime to a Julian Day. The JD-system is used by astronomers.
The text was updated successfully, but these errors were encountered: