Download javascript
Download profile

Please note: you may need to rename the JavaScript file or edit its filename in the profile to make them work together.


To calculate the sunrise, sunset and the twilight times for a given location, which the phone gets by GPS (net). The times are shown by PopUp and the sunrise/sunset is saved in global variables as well.

Usage instructions

Download the javascript file and save it in the Tasker/JavaScript directory or point in the task to where you saved the javascript file.

The example profile will run once a day at 00:01 o'clock and set the variables %SUNSET and %SUNRISE to the appropriate times, it will show a PopUp with all times.

The script also returns the twilight times as follows:

%at_start Astronomical twilight start
%nt_start Nautical twilight start
%ct_start Civil twilight start
%rise Sunrise
%set Sunset
%ct_end Civil twilight end
%nt_end Nautical twilight end
%at_end Astronomical twilight end


version description
20220526 Fixes a bug in function calcSunriseSet that's been there since the script's inception (mixed use of deltatwilight and deltaTwilight), that caused the script to fail for certain locations and dates.
(I'm guessing this is the bug that francwalter tried to work around in version 5 by putting the calculations of Astronomical twilight at the end of the file.)
6 Fixed a bug (lat lon example not commented out), uploaded to sunriseset3.js (no right to delete the previous file)
5 (Half)fixed (quick+dirty) the sunriseset.js (bug with at), uploaded to sunriseset2.js
4 Works in Tasker v4 now, bugfix in JS (new file), bugfix in profile (new file)
3 Added twilight times. Further DST fixes - please email me if this fails in your TZ.
2 Corrected for Daylight Savings Time.
1 Initial version.


Adapted from the NOAA Solar Calculator.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License