#include <date.h>
#include <iostream>
+#include "location.h"
+
// Calculate the time of sunrise in timezone UTC.
-hour calculate_sunrise(double latitude, double longitude, date when)
+hour Location::calculate_sunrise(date when)
{
float Declanation;
float solaroffset;
// Calculate the time of sunset in timezone UTC.
-hour calculate_sunset(double latitude, double longitude, date when)
+hour Location::calculate_sunset(date when)
{
float Declanation;
float solaroffset;
}
+UTC Location::utc_to_localtime(date when, hour utc_time)
+{
+ struct tm tp_utc;
+ time_t utc_t;
+ struct tm *local_tm;
+
+
+ tp_utc.tm_year = when.Year() - 1900;
+ tp_utc.tm_mon = when.Month() - 1;
+ tp_utc.tm_mday = when.Day();
+ tp_utc.tm_hour = utc_time.Hour();
+ tp_utc.tm_min = utc_time.Minute();
+ tp_utc.tm_sec = utc_time.Second();
+ tp_utc.tm_isdst = -1;
+
+ utc_t = timegm(&tp_utc);
+
+ local_tm = localtime(&utc_t);
+ UTC local_time(mktime(local_tm));
+
+ return local_time;
+
+}
+