This Rust application calculates the sunrise and sunset times for a given date, time, latitude, and longitude. It is based on the NOAA Global Monitor Division's solar position calculations. The original formulas can be found here: https://gml.noaa.gov/grad/solcalc/solareqns.PDF
- Calculates sunrise and sunset times based on the specified date, time, latitude, and longitude.
- Utilizes the fractional year in radians to determine the position of the sun.
- Implements the equation of time to account for the Earth's elliptical orbit.
- Calculates solar declination for accurate results.
- Adjusts times to the specified timezone.
- Ensure you have Rust installed on your system. If not, install it from the official Rust website.
- Clone this repository to your local machine.
- Navigate to the project directory and build the project using Cargo:
cargo build --release
To use the application, run it with the following arguments:
./solar <date> <time> <latitude> <longitude> [time_zone]
date
: The date for which you want to calculate sunrise and sunset times (format: YYYY-MM-DD).time
: The local time to base the calculations on (format: HH:MM:SS).latitude
: The latitude of the location in decimal degrees.longitude
: The longitude of the location in decimal degrees.timezone
: IANA timezone format, optional. Defaults to "America/New_York"
Example:
> ./solar 2024-01-11 12:00:00 40.7128 -74.0060 "America/New_York"
▲ 2024-01-11 07:21:00 EST ▼ 2024-01-11 16:55:00 EST
This command calculates the sunrise and sunset times for New York City on January 11, 2024, at noon.
I dont care. Use it for whatever, however you please.