Index: /trunk/MagicSoft/Mars/mastro/MAstro.cc
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 4563)
+++ /trunk/MagicSoft/Mars/mastro/MAstro.cc	(revision 4564)
@@ -503,31 +503,36 @@
 // after Jan 1st 1980 (which was @ MJD=44240.37917)
 //
-// In a addition to this calculation an offset of 284 periods is substracted.
-// Taking this offset into account you get the Period as it is defined
-// for the MAGIC observations. If you want to get the MAGIC observation
-// period number make sure that your Mjd is a integer without a floating
-// point reminder.
+Double_t MAstro::GetMoonPeriod(Double_t mjd)
+{
+    const Double_t synmonth = 29.53058868; // synodic month (new Moon to new Moon)
+    const Double_t epoch0   = 44240.37917; // First full moon after 1980/1/1
+
+    const Double_t et = mjd-epoch0; // Ellapsed time
+    return TMath::Floor(et/synmonth);
+}
+
+// --------------------------------------------------------------------------
+//
+// To get the moon period as defined for MAGIC observation we take the
+// nearest integer mjd, eg:
+//   53257.8 --> 53258
+//   53258.3 --> 53258
+// Which is the time between 13h and 12:59h of the following day. To
+// this day-period we assign the moon-period at midnight. To get
+// the MAGIC definition we now substract 284.
 //
 // For MAGIC observation period do eg:
-//   GetMoonPeriod(53257)
+//   GetMagicPeriod(53257.91042)
 // or
 //   MTime t;
-//   t.SetMjd(53257);
-//   GetMoonPeriod(t.GetMjd());
+//   t.SetMjd(53257.91042);
+//   GetMagicPeriod(t.GetMjd());
 // or
 //   MTime t;
-//   t.Set(2004, 1, 1, 0);
-//   GetMoonPeriod(t.GetMjd());
-// or
-//   MTime t;
-//   t.Now();
-//   GetMoonPeriod(TMath::Floor(t.GetMjd()));
-//
-Double_t MAstro::GetMoonPeriod(Double_t mjd, Int_t offset)
-{
-    const Double_t synmonth = 29.53058868; // synodic month (new Moon to new Moon)
-    const Double_t epoch0   = 44240.37917; // First full moon after 1980/1/1
-
-    const Double_t et = mjd-epoch0; // Ellapsed time
-    return TMath::Floor(et/synmonth) + offset;
-}
+//   t.Set(2004, 1, 1, 12, 32, 11);
+//   GetMagicPeriod(t.GetMjd());
+//
+Double_t MAstro::GetMagicPeriod(Double_t mjd)
+{
+    return GetMoonPeriod(TMath::Nint(mjd))-284;
+}
Index: /trunk/MagicSoft/Mars/mastro/MAstro.h
===================================================================
--- /trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 4563)
+++ /trunk/MagicSoft/Mars/mastro/MAstro.h	(revision 4564)
@@ -57,5 +57,6 @@
 
     static Double_t GetMoonPhase(Double_t mjd);
-    static Double_t GetMoonPeriod(Double_t mjd, Int_t offset=-284);
+    static Double_t GetMoonPeriod(Double_t mjd);
+    static Double_t GetMagicPeriod(Double_t mjd);
 
     ClassDef(MAstro, 0)
