0
sunrise and sunset
Would any of you who live in a different time zone than CET be kind enough to test my script? It displays the sunrise and sunset at the site. The accuracy is about two minutes. You still have to change the longitude and latitude in lines 2 and 3. I think it works but I couldn't test it myself. You can check the result, for example, on www.timeanddate.com. I don't understand English well, please write me back in simple sentences. It would be nice if someone could spare the time for an answer.
Greeting. Mirko
let myDate := today();
let lat := 51.9959;
let long := 12.3017;
let breiteRad := radians(lat);
let minute := number(extractx(format(myDate, "Z"), "\d+(?=$)"));
let hour := number(extractx(format(myDate, "Z"), "\d+(?=:)"));
let timeZone := number(time(hour, minute)) / 1000 / 60 / 60;
let dayCount := days(date(year(myDate), 1, 0), date(year(myDate), month(myDate), day(myDate))) + 1;
let deklination := 0.4095 * sin(0.016906 * (dayCount - 80.086));
let zeitdifferenz := 12 * acos((sin(-0.0145) - sin(breiteRad) * sin(deklination)) / (cos(breiteRad) * cos(deklination))) / 3.14159;
let zeitgleichung := -0.171 * sin(0.0337 * dayCount + 0.465) - 0.1299 * sin(0.01787 * dayCount - 0.168);
let sunUP := 12 - zeitdifferenz - zeitgleichung;
let sunUPCorr := sunUP - long / 15 + timeZone;
let sunrise := time(sunUPCorr, 0);
let sunDOWN := 12 + zeitdifferenz - zeitgleichung;
let sunDOWNCorr := sunDOWN - long / 15 + timeZone;
let sunset := time(sunDOWNCorr, 0);
let result := "sunrise " + sunrise + " " + "sunset " + sunset;
result
Reply
Content aside
- 2 yrs agoLast active
- 47Views
-
1
Following