Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Solar Calculator - Calculate Sunrise, Sunset, and Maximum Solar Radiation

, 10 Jan 2011 CPOL
A C# assembly for calculating Sunrise, Sunset, and Maximum Solar Radiation
// SunCalculator.cs - Calculator for calculating SunRise, SunSet and
// maximum solar radiation of a specific date and time.
// Patrick Kalkman
// (C) Patrick Kalkman
using System;
using Astronomy;

namespace ConsoleCalculator
   class Program
      static void Main(string[] args)
         const Double LongituteUtrechtNetherlands = 5.127869;
         const Double LatitudeUtrechtNetherlands = 52.108192;

         SunCalculator sunCalculator = new SunCalculator(LongituteUtrechtNetherlands, LatitudeUtrechtNetherlands, 15, false);
         //Calculate the sunrise for the city Utrecht in the Netherlands 
         DateTime startDateTime = new DateTime(2010, 1, 1);
         DateTime endDateTime = new DateTime(2010, 3, 31);
         DateTime dateTime = startDateTime;
         while (dateTime < endDateTime)
            DateTime sunRise = sunCalculator.CalculateSunRise(dateTime);
            Console.WriteLine("On {0:MM/dd/yyyy} the sun rises at {1:t}", dateTime, sunRise);
            dateTime = dateTime.AddDays(1);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Patrick Kalkman
Netherlands Netherlands
Patrick Kalkman is a senior Software Architect with more than 20 years professional development experience. He works for Hinttech where he develops state of the art web applications.

Patrick enjoys writing his blog. It discusses software architectures using semantic web technologies. Patrick can be reached at
Published Windows 8 apps:
Published Windows Phone apps:

Best Mobile article of March 2012
Best Mobile article of June 2012
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 10 Jan 2011
Article Copyright 2010 by Patrick Kalkman
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid