Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a simple open-source, command-line program that can show the sunrise and sunset times at a given date and location, and perhaps moon and planet data as well?

Browsing the Debian package database and Google searches, I can't find anything relevant. This surprises me — considering the number of people who are both astronomy geeks and unix geeks, I'd have expected a de-facto-standard sunrise(1) (or perhaps sunrise(6)).

I am not interested in more complex programs that incidentally perform the calculations, such as sky maps (celestia, kstars, starplot, stellarium), earth maps (sunclock, xplanet), calendars/agendas (emacs, remind), clocks (glunarclock, wmsun), tide almanachs (xtide). There is perhaps aa (astronomical-almanac), but I don't see a simple way of asking it what time the sun will rise on this date at these longitude and latitude.

What did I miss?

share|improve this question

3 Answers 3

Did you try sunwait?

http://www.risacher.org/sunwait/

Sunwait is a small C program for calculating sunrise and sunset, as well as civil, nautical, and astronomical twilights. [..]

share|improve this answer
up vote 3 down vote accepted

I ended up using Perl's DateTime::Event::Sunrise, because it tends to be easier for me to deploy a module from CPAN than to compile C programs.

Sample usage:

use DateTime;
use DateTime::Astro::Sunrise;
$latitude = "+48.857"; $longitude = "+2.351"; 
$sr = DateTime::Astro::Sunrise->new($longitude, $latitude, 0, 3);
$date = DateTime->now; $date->set_time_zone("local");
($rise, $set) = $sr->sunrise($date);
$rise->set_time_zone("local"); $set->set_time_zone("local");
print $rise, " to ", $set, "\n";

My sunrise script.

share|improve this answer

Check out this Linux Home Automation site and search the page for "sunrise". There are some command line programs there from c. 1985 that are pretty minimalist. I have the source code for a number of related programs from that era, but I can't find them on the web.

Update: I just found the source for a few others, including sdate, on this Event Logger page. Search the page for "rise_set".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.