![]() |
VOOZH | about |
dotnet add package SolarCalculator --version 3.6.1
NuGet\Install-Package SolarCalculator -Version 3.6.1
<PackageReference Include="SolarCalculator" Version="3.6.1" />
<PackageVersion Include="SolarCalculator" Version="3.6.1" />Directory.Packages.props
<PackageReference Include="SolarCalculator" />Project file
paket add SolarCalculator --version 3.6.1
#r "nuget: SolarCalculator, 3.6.1"
#:package SolarCalculator@3.6.1
#addin nuget:?package=SolarCalculator&version=3.6.1Install as a Cake Addin
#tool nuget:?package=SolarCalculator&version=3.6.1Install as a Cake Tool
👁 GitHub Workflow Status (with branch)
Calculates the sunrise and sunset for a given date and location (using GEO coordinates). This library uses the method outlined NOAA Solar Calculations Day spreadsheet found at http://www.esrl.noaa.gov/gmd/grad/solcalc/calcdetails.html.
Add this to your project in Visual Studio using NuGet Package Manager UI and ID SolarCalculator or using the Package Manager Console.
PM> Install-Package SolarCalculator
Starting in version 3.3.0 there are two new properties for checking if a date is a Polar Day (IsPolarDay) or Polar Night (IsPolarNight). If the combination of date and location result in a Polar Day or Polar Night, the values for Sunrise and Sunset are as follows:
Polar Day: Sunrise = DateTime.MinValue, Sunset = DateTime.MaxValue
Polar Night: Sunrise = DateTime.MaxValue, Sunset = DateTime.MinValue
The sample code below shows how to initialize and call the Solar Calculator to get the sunrise and sunset for the given location.
using System;
using Innovative.SolarCalculator;
//
// Geo coordinates of Oak Street Beach in Chicago, IL
//
// NOTE: the .Date is not necessary but is included to demonstrate that time input
// does not affect the output. Time will be returned in the current time zone so it
// will need to be adjusted to the time zone where the coordinates are from (there
// are services that can be used to get time zone from a latitude and longitude position).
//
TimeZoneInfo cst = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
SolarTimes solarTimes = new SolarTimes(DateTime.Now.Date, 41.9032, -87.6224);
DateTime sunrise = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunrise.ToUniversalTime(), cst);
//
// Display the sunrise
//
Console.WriteLine($"View the sunrise across Lake Michigan from Oak Street Beach in Chicago at {sunrise.ToLongTimeString()} on {sunrise.ToLongDateString()}.");
//
// Geo coordinates of Benton Harbor/Benton Heights in Michigan
//
TimeZoneInfo est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
SolarTimes solarTimes = new SolarTimes(DateTime.Now, 42.1543, -86.4459);
DateTime sunset = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunset.ToUniversalTime(), est);
//
// Display the sunset
//
Console.WriteLine($"View the sunset across Lake Michigan from Benton Harbor in Michigan at {sunset.ToLongTimeString()} on {sunset.ToLongDateString()}.");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 is compatible. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net40 net40 is compatible. net403 net403 was computed. net45 net45 is compatible. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on SolarCalculator:
| Package | Downloads |
|---|---|
|
NetDaemon.Extensions.Scheduling
Scheduling features for NetDaemon. Please see https://github.com/net-daemon/netdaemon. |
|
|
ColorTurbine.Framework
LED animation/information display framework |
|
|
CasCap.Api.Knx
.NET client library for KNX building automation — connects via KNXnet/IP tunnelling or routing, monitors group-address telegrams, and fans events out to configurable sinks. |
Showing the top 1 popular GitHub repositories that depend on SolarCalculator:
| Repository | Stars |
|---|---|
|
net-daemon/netdaemon
An application daemon for Home Assistant written in .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.6.1 | 11,232 | 4/15/2026 |
| 3.6.0 | 55,964 | 11/15/2025 |
| 3.5.0 | 120,956 | 11/14/2024 |
| 3.4.0 | 40,835 | 9/11/2024 |
| 3.3.0 | 195,746 | 5/30/2023 |
| 3.2.1 | 35,831 | 12/2/2022 |
| 3.2.0 | 1,664 | 12/2/2022 |
| 3.1.0 | 148,806 | 1/15/2022 |
| 3.0.6 | 142,816 | 8/4/2020 |
| 3.0.5 | 33,771 | 4/17/2020 |
| 3.0.4 | 1,931 | 4/16/2020 |
| 3.0.3 | 2,009 | 4/14/2020 |
| 3.0.2 | 1,958 | 4/14/2020 |
| 3.0.1 | 4,305 | 1/25/2020 |
| 2.0.4 | 53,202 | 10/17/2018 |
| 2.0.3 | 4,195 | 7/10/2018 |
| 2.0.2 | 14,565 | 10/2/2017 |
| 2.0.1 | 2,620 | 10/1/2017 |
| 2.0.0 | 2,908 | 9/29/2017 |
v3.6.1 Fix DST transition day sunrise/sunset offset bug. Removed NET 7.
v3.6.0 Added net 10.0 support. Removed netstandard 1.3 support.
v3.5.0 Added net 9.0 support.
v3.4.0 Added net 8.0 support.
v3.3.0 Corrections added for Polar Day and Polar Night (Nickztar)
v3.2.1 Added ReadMe to package.
v3.2.0 Added net 7.0 support.
v3.1.0 Added support for net 5.0 and net 6.0.
v3.0.6 Added calculations for Astronomical, Nautical and Civil Dawn and Dusk times (rbdavison).
v3.0.5 Reverted changes until further research can be done.
v3.0.4 Corrected date shifting issue.
v3.0.3 Added missing documentation.
v3.0.2 Added source code and symbol integration to NuGet package.
v3.0.1 Changed license to LGPL Public 3.0.
v3.0.0 Added support for multiple frameworks.
v2.0.4 Bug Fix - Removed internal date setting by string that was not compatible in all locales - t1m0thyj
v2.0.3 Added azimuth calculation - GeorgeHahn
v2.0.2 Corrected date portion of SolarNoon date and time. It was showing the correct time but the wrong day.
v2.0.1 Change default value for SolarNoon to the ForDate property.
v2.0.0 Converted to .NET Standard/Moved to GitHub.
v1.0.8 Added multiple .NET versions.
v1.0.7 Removed Angle class and referenced it from NuGet library.
v1.0.6 Updated NuGet package only.
v1.0.5 Added a class/data type called Angle to handle computations and conversions. This class inherently behaves as a type double so that pre-existing code is not broken.
v1.0.4 Change the type of ForDate to DateTimeOffset due to improper handling of Time Zone. This does not affected code already written against this method.
v1.0.3 Corrected a time issue causing the wrong sunrise and sunset times to be returned. All test cases passed.
v1.0.2 Added XML comments file.
v1.0.1 Updated license and project URL's in package.