notes from /dev/null

by Charles Choi 최민수


Sunrise and Sunset in Emacs

09 May 2024  Charles Choi

We’ve been having great weather this past week in San Francisco, where the days have been balmy. I enjoy being outside in the early evening, and often wonder when sunset is. As it turns out, Emacs has a command to help answer that: sunrise-sunset. Running it will display the sunrise and sunset times for the current day in the mini-buffer.

Before you use sunrise-sunset, you’ll need to customize two variables to establish your location:

  • calendar-latitude
  • calendar-longitude

Use your maps app/website to help find those values and set them appropriately with either the command customize-variable or your configuration method of choice.

Once done, run M-x sunrise-sunset to get the sunrise and sunset times for the current day.

If you want the sunrise and sunset times for a different date, use C-u M-x sunrise-sunset. You’ll be prompted for the year, month, and day.

If you are in an Org Agenda or Calendar (calendar) window, you can get the sunrise and sunset times for the day the point is on by pressing S.

In the rare event of Emacs not being able to get the correct time zone from your operating system, you can set some variables manually as described in the Emacs manual. Regardless, use your favorite weather app/website to confirm that the sunrise and sunset times being returned by Emacs are correct.

Hope that this knowledge brings you as much joy as its done for me. I’ve used this to plan for many a great day.

References

emacs

 

AboutMastodonInstagramGitHub

Feeds & TagsGet Captee for macOS

Powered by Pelican