Hello,
This B4A routine returns a correct value,
however, the equivalent routine in Java does not
Question being, am I totally mad? Can't see any difference, though.
If someone has got a minute...
Thanks & Cheers
This B4A routine returns a correct value,
B4X:
'Returns the equation of time in minutes decimal.
'x = Date in Ticks, such as DateTme.Now
Public Sub GetEOT(x As Long) As Double
'ref [url=http://en.wikipedia.org/wiki/Equation_of_time]Equation of time - Wikipedia, the free encyclopedia[/url]
Dim w, a, b, c As Double
Dim n As Int
n = DateTime.GetDayOfYear(x)
w = 360 / 365.242199
a = w * (n + 10)
b = a + 1.9149659 * SinD(w * (n-2)) '1.91... = 360 / cPI * 0.0167... ecc of earth
c = (a - ATanD(TanD(b) / CosD(23.43755447))) / 180
Return 720 * (c - Round(c))
End Sub
however, the equivalent routine in Java does not
B4X:
/**
* Returns the equation of time in minutes decimal.
* @param x Ticks
* @return EOT
*/
public double GetEOT(long x) {
//ref [url=http://en.wikipedia.org/wiki/Equation_of_time]Equation of time - Wikipedia, the free encyclopedia[/url]
int n = DateTime.GetDayOfYear(x); //returned day of year is correct
double w = 360 / 365.242199;
double a = w * (n + 10);
double b = a + 1.9149659 * Math.sin((w/Rad) * (n-2)); // Rad = 57.3
double c = (a - Math.atan(Math.tan(b/Rad) / Math.cos(23.43755447/Rad))) / 180;
double eot = 720 * (c - Math.round(c));
return eot;
}
Question being, am I totally mad? Can't see any difference, though.
If someone has got a minute...
Thanks & Cheers