Hi
I use Julian Date Time UTC as doubles in my real-time systems. Of course its pretty hard to work out the date and time by looking at the number:
2459008.73432 = 2020/06/08 05:37:25
Calculated using:
On-Line Converter - Julian Date
I found an algorithm written by D. C. Tyler in C which may be found among other web sites on:
DateTime.c
The beauty of this algorithm is that it includes time. It is based on an algorithm developed by Robert Tanzin which can be found on:
Algorithm 199: conversions between calendar date and Julian day number
I originally used the algorithm with just a few minor mods in a embedded C program and later converted it into Visual Basic for use in MS Access.
Its tricky because the data types in basic are different from c and so truncation and rounding must be carried out to get the correct result.
I have also converted it for use in B4X and have attached the module for others to use. I cannot guarantee it, but it hasn't failed so far over the small time I have used it.
If you wish to use it over a wide range of dates i.e centuries then I'd give it a good test first. It's currently programmed as a single instance code module.
Perhaps someone might like to convert it to a class and post this.
It's probably not very efficiently coded for B4X as I am not good at Object Oriented programming, but it does work.
Best regards
Rob
I use Julian Date Time UTC as doubles in my real-time systems. Of course its pretty hard to work out the date and time by looking at the number:
2459008.73432 = 2020/06/08 05:37:25
Calculated using:
On-Line Converter - Julian Date
I found an algorithm written by D. C. Tyler in C which may be found among other web sites on:
DateTime.c
The beauty of this algorithm is that it includes time. It is based on an algorithm developed by Robert Tanzin which can be found on:
Algorithm 199: conversions between calendar date and Julian day number
I originally used the algorithm with just a few minor mods in a embedded C program and later converted it into Visual Basic for use in MS Access.
Its tricky because the data types in basic are different from c and so truncation and rounding must be carried out to get the correct result.
I have also converted it for use in B4X and have attached the module for others to use. I cannot guarantee it, but it hasn't failed so far over the small time I have used it.
If you wish to use it over a wide range of dates i.e centuries then I'd give it a good test first. It's currently programmed as a single instance code module.
Perhaps someone might like to convert it to a class and post this.
It's probably not very efficiently coded for B4X as I am not good at Object Oriented programming, but it does work.
Best regards
Rob