batoulapps / adhan-kotlin

High precision Islamic prayer time library for Java
MIT License
161 stars 47 forks source link

How to show times with seconds? #4

Closed abdeldjalil-fellah closed 5 years ago

abdeldjalil-fellah commented 6 years ago

I used this formatter:

SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");

but seconds were not shown

z3bi commented 6 years ago

This library rounds the prayer times to the nearest minute. Otherwise most apps that display only hour and minute would show 8:03 PM when the actual time was 8:03:59 PM and it would be more correct to show 8:04 PM.

abdeldjalil-fellah commented 6 years ago

It would be great to add a parameter for timezone and rounding seconds

z3bi commented 6 years ago

As mentioned in the README time zones are handled through the formatter. This is the correct way to return a date object and avoids the issue of accidentally applying a timezone offset twice.

z3bi commented 6 years ago

Can you explain the scenario why you want to show seconds? It would help us to understand how/why the library should make it a parameter.

abdeldjalil-fellah commented 6 years ago

It is actually to know the exact time mentioned here http://praytimes.org/wiki/A_note_on_Dhuhr

z3bi commented 6 years ago

The library already accounts for that situation. You can see the 1 minute added to Dhuhr for most calculation methods here https://github.com/batoulapps/adhan-java/blob/master/adhan/src/main/java/com/batoulapps/adhan/CalculationMethod.java

Abu-Abdullah commented 4 years ago

@z3bi

sorry to revive this case. i would think having the resolution to seconds is a good option here. rounding it to minutes is also a developer choice. it shows how much precise this library is

z3bi commented 4 years ago

@Abu-Abdullah no need to apologize, one of the main goals of this library is for this to be developed in the open and allow for peer discussion of these important issues.

The main reason that we round to the nearest minute is that in our source material, "Astronomical Algorithms" by Jean Meeus he says that because the value we use for refraction is a mean value that shifts based on atmospheric conditions, accuracy beyond the nearest minute does not make sense.

From Astronomical Algorithms page 107

Screen Shot 2020-06-28 at 1 36 48 PM

Because of that I am hesitant to even provide the seconds, as it would make it seem that the equations are able to produce a level of accuracy which is not actually possible without knowing things like temperature, atmospheric pressure and other information.

z3bi commented 4 years ago

The precision this library offers is by not doing any rounding of the intermediate steps or using "approximate" equations. The calculations are done with full precision and then the end result is rounded to the smallest unit which we can fully claim to be able to represent.

Abu-Abdullah commented 4 years ago

thank you for the informative answer