Index: trunk/MagicSoft/Mars/mbase/MAstro.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MAstro.cc	(revision 2858)
+++ trunk/MagicSoft/Mars/mbase/MAstro.cc	(revision 2891)
@@ -216,6 +216,6 @@
 Int_t MAstro::Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d)
 {
-   // Month lengths in days
-   static int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+    // Month lengths in days
+    static int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
 
     // Validate month
@@ -230,9 +230,9 @@
         return -1;
 
-    // Lengthen year and month numbers to avoid overflow
+    // Precalculate some values
     const Byte_t  lm = 12-m;
-    const ULong_t lm10 = 4712 + y + lm/10;
+    const ULong_t lm10 = 4712 + y - lm/10;
 
     // Perform the conversion
-    return 1461L*lm10/4 + (306*((21-lm)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
-}
+    return 1461L*lm10/4 + (306*((m+9)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
+}
