Index: /trunk/FACT++/src/Time.cc
===================================================================
--- /trunk/FACT++/src/Time.cc	(revision 18965)
+++ /trunk/FACT++/src/Time.cc	(revision 18966)
@@ -27,10 +27,10 @@
 #include "Time.h"
 
-#ifdef HAVE_LIBNOVA
-#include "../externals/nova.h"
-#endif
-
 using namespace std;
 using namespace boost::posix_time;
+
+#ifdef HAVE_LIBNOVA
+#include "externals/nova.h"
+#endif
 
 const boost::gregorian::date Time::fUnixOffset(1970, 1, 1);
@@ -303,26 +303,29 @@
 //! @returns
 //!     The time of the previous sun-rise, relative to given horizon in degree,
-//!     for the coordinates of the ORM, La Palma.
-//!     if libnova was not compiled in, it will return the next noon.
+//!     for the observatory location given (see nova.h).
+//!     If the sun is circumpolar, it simply return the intgeral fraction of
+//!     the current MJD.
+//!     If libnova was not compiled in, it will return the next noon.
 //!
 //!  @throws
-//!     a runtime_error exception is thrown if the calculation of the sun-rise
-//!     by libnova fails (this would happen if libnova thinks the sun is
-//!     circumpolar which should never happen at La Palma)
-//
-Time Time::GetPrevSunRise(double horizon) const
+//!     A runtime_error exception is thrown if the observatory location
+//!     is not defined (see nova.h)
+//
+Time Time::GetPrevSunRise(double horizon, const string &obs) const
 {
 #ifdef HAVE_LIBNOVA
-    Nova::LnLatPosn obs = Nova::kORM;
+    const Nova::LnLatPosn posn(obs);
+    if (!posn.isValid())
+        throw runtime_error("Observatory location '"+obs+"' unknown.");
 
     ln_rst_time sun_day;
-    if (ln_get_solar_rst_horizon(JD()-0.5, &obs, horizon, &sun_day)==1)
-        throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");
+    if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1)
+        return Time(floor(Mjd()));
 
     if (Time(sun_day.rise)<*this)
         return Time(sun_day.rise);
 
-    if (ln_get_solar_rst_horizon(JD()-1.5, &obs, horizon, &sun_day)==1)
-        throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");
+    if (ln_get_solar_rst_horizon(JD()-1.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1)
+        return Time(floor(Mjd()));
 
     return Time(sun_day.rise);
@@ -336,30 +339,33 @@
 //! @returns
 //!     The time of the next sun-rise, relative to given horizon in degree,
-//!     for the coordinates of the ORM, La Palma.
-//!     if libnova was not compiled in, it will return the next noon.
+//!     for the observatory location given (see nova.h).
+//!     If the sun is circumpolar, it simply return the intgeral fraction of
+//!     the current MJD+1.
+//!     If libnova was not compiled in, it will return the next noon.
 //!
 //!  @throws
-//!     a runtime_error exception is thrown if the calculation of the sun-rise
-//!     by libnova fails (this would happen if libnova thinks the sun is
-//!     circumpolar which should never happen at La Palma)
-//
-Time Time::GetNextSunRise(double horizon) const
+//!     A runtime_error exception is thrown if the observatory location
+//!     is not defined (see nova.h)
+//
+Time Time::GetNextSunRise(double horizon, const string &obs) const
 {
 #ifdef HAVE_LIBNOVA
-    Nova::LnLatPosn obs = Nova::kORM;
+    const Nova::LnLatPosn posn(obs);
+    if (!posn.isValid())
+        throw runtime_error("Observatory location '"+obs+"' unknown.");
 
     ln_rst_time sun_day;
-    if (ln_get_solar_rst_horizon(JD()-0.5, &obs, horizon, &sun_day)==1)
-        throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");
+    if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1)
+        return Time(floor(Mjd())+1);
 
     if (Time(sun_day.rise)>=*this)
         return Time(sun_day.rise);
 
-    if (ln_get_solar_rst_horizon(JD()+0.5, &obs, horizon, &sun_day)==1)
-        throw runtime_error("ln_get_solar_rst_horizon reported the sun to be circumpolar at the coordinates of La Palma!");
+    if (ln_get_solar_rst_horizon(JD()+0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1)
+        return Time(floor(Mjd())+1);
 
     return Time(sun_day.rise);
 #else
-    return Time(floor(Mjd()+0.5))+0.5;
+    return Time(floor(Mjd()+0.5)+0.5);
 #endif
 }
@@ -369,7 +375,11 @@
 //! Calls GetPrevSunRise(LN_SOLAR_STANDART_HORIZON)
 //
-Time Time::GetPrevSunRise() const
-{
-    return GetPrevSunRise(LN_SOLAR_STANDART_HORIZON);
+Time Time::GetPrevSunRise(const string &obs) const
+{
+#ifdef HAVE_LIBNOVA
+    return GetPrevSunRise(LN_SOLAR_STANDART_HORIZON, obs);
+#else
+    return GetPrevSunRise(-0.8333, obs);
+#endif
 }
 
@@ -378,7 +388,11 @@
 //! Calls GetNextSunRise(LN_SOLAR_STANDART_HORIZON)
 //
-Time Time::GetNextSunRise() const
-{
-    return GetNextSunRise(LN_SOLAR_STANDART_HORIZON);
+Time Time::GetNextSunRise(const string &obs) const
+{
+#ifdef HAVE_LIBNOVA
+    return GetNextSunRise(LN_SOLAR_STANDART_HORIZON, obs);
+#else
+    return GetNextSunRise(-0.8333, obs);
+#endif
 }
 
@@ -395,7 +409,7 @@
 //!     24h period between two noon's.
 //
-uint32_t Time::NightAsInt() const
-{
-    const Time tm = GetPrevSunRise();
+uint32_t Time::NightAsInt(const string &obs) const
+{
+    const Time tm = GetPrevSunRise(obs);
     return tm.Y()*10000 + tm.M()*100 + tm.D();
 }
Index: /trunk/FACT++/src/Time.h
===================================================================
--- /trunk/FACT++/src/Time.h	(revision 18965)
+++ /trunk/FACT++/src/Time.h	(revision 18966)
@@ -114,11 +114,11 @@
     std::string SecondsTo(const Time & = Time()) const;
 
-    Time GetPrevSunRise(double horizon) const;
-    Time GetNextSunRise(double horizon) const;
+    Time GetPrevSunRise(double horizon, const std::string &obs="ORM") const;
+    Time GetNextSunRise(double horizon, const std::string &obs="ORM") const;
 
-    Time GetPrevSunRise() const;
-    Time GetNextSunRise() const;
+    Time GetPrevSunRise(const std::string &obs="ORM") const;
+    Time GetNextSunRise(const std::string &obs="ORM") const;
 
-    uint32_t NightAsInt() const;
+    uint32_t NightAsInt(const std::string &obs="ORM") const;
 };
 
