Index: /trunk/FACT++/src/datalogger.cc
===================================================================
--- /trunk/FACT++/src/datalogger.cc	(revision 15337)
+++ /trunk/FACT++/src/datalogger.cc	(revision 15338)
@@ -245,5 +245,5 @@
     int infoCallback(const EventImp& evt, unsigned int infoIndex);
 
-    Time GetSunRise(const Time &time=Time());
+//    Time GetSunRise(const Time &time=Time());
 
     /***************************************************
@@ -866,5 +866,5 @@
         CreateDirectory(str.str());
 
-    str << '/' << CompileFileName(service, extension, fCurrentDay);
+    str << '/' << CompileFileName(service, extension, ftime);//fCurrentDay);
 
     return str.str();
@@ -928,5 +928,5 @@
     //the next closing time is 30 minutes after upcoming sunrise.
     //If we are within 30 minutes after sunrise, closing time is soon
-    fCurrentDay = GetSunRise(Time()-boost::posix_time::minutes(30)) + boost::posix_time::minutes(30);//(int)(nowMinusTwelve.Mjd());//nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year
+    fCurrentDay = Time().GetNextSunRise();//GetSunRise(Time()-boost::posix_time::minutes(30)) + boost::posix_time::minutes(30);//(int)(nowMinusTwelve.Mjd());//nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year
     lastFlush = Time();
 
@@ -1133,4 +1133,5 @@
         fAutoStarted = true;
         SetCurrentState(Start());
+//        SetCurrentState(NightlyToWaitRun());
     }
     else
@@ -1271,4 +1272,5 @@
 //! Used to know when to close and reopen files
 //!
+/*
 Time DataLogger::GetSunRise(const Time &time)
 {
@@ -1303,5 +1305,5 @@
 #endif
 }
-
+*/
 // --------------------------------------------------------------------------
 //
@@ -1357,5 +1359,5 @@
     {
         //set the next closing time. If we are here, we have passed 30 minutes after sunrise.
-        fCurrentDay = GetSunRise(timeNow-boost::posix_time::minutes(30))+boost::posix_time::minutes(30);
+        fCurrentDay = timeNow.GetNextSunRise();//GetSunRise(timeNow-boost::posix_time::minutes(30))+boost::posix_time::minutes(30);
         //crawl through the subcriptions and close any open nightly file
         SubscriptionsListType::iterator x;
