Special calendar commands can tell you, to within a minute or two, the times of sunrise and sunset for any date.
Display times of sunrise and sunset for the selected date
Display times of sunrise and sunset for today’s date.
Display times of sunrise and sunset for a specified date.
Display times of sunrise and sunset for the selected month.
Within the calendar, to display the local times of sunrise and sunset in the echo area, move point to the date you want, and type S. Alternatively, click mouse-3 on the date, then choose ‘Sunrise/sunset’ from the menu that appears. The command M-x sunrise-sunset is available outside the calendar to display this information for today’s date or a specified date. To specify a date other than today, use C-u M-x sunrise-sunset, which prompts for the year, month, and day.
You can display the times of sunrise and sunset for any location and any date with C-u C-u M-x sunrise-sunset. This asks you for a longitude, latitude, number of minutes difference from Coordinated Universal Time, and date, and then tells you the times of sunrise and sunset for that location on that date.
Because the times of sunrise and sunset depend on the location on earth, you need to tell Emacs your latitude, longitude, and location name before using these commands. Here is an example of what to set:
(setq calendar-latitude 40.1) (setq calendar-longitude -88.2) (setq calendar-location-name 'Urbana, IL')
Use one decimal place in the values of
Your time zone also affects the local time of sunrise and sunset. Emacs usually gets time zone information from the operating system, but if these values are not what you want (or if the operating system does not supply them), you must set them yourself. Here is an example:
(setq calendar-time-zone -360) (setq calendar-standard-time-zone-name 'CST') (setq calendar-daylight-time-zone-name 'CDT')
The value of
calendar-time-zone is the number of minutes
difference between your local standard time and Coordinated Universal
Time (Greenwich time). The values of
calendar-daylight-time-zone-name are the abbreviations used in
your time zone. Emacs displays the times of sunrise and sunset
corrected for daylight saving time. See Daylight Saving,
for how daylight saving time is determined.
As a user, you might find it convenient to set the calendar location variables for your usual physical location in your .emacs file. If you are a system administrator, you may want to set these variables for all users in a default.el file. See Init File.