Index: trunk/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 8544)
+++ trunk/MagicSoft/Mars/mbase/MTime.cc	(revision 8551)
@@ -89,6 +89,7 @@
 using namespace std;
 
-const UInt_t MTime::kHour = 3600000;         // [ms] one hour
-const UInt_t MTime::kDay  = MTime::kHour*24; // [ms] one day
+const UInt_t MTime::kHour   = 3600000;         // [ms] one hour
+const UInt_t MTime::kDay    = MTime::kHour*24; // [ms] one day
+const UInt_t MTime::kDaySec = 3600*24;         // [s] one day
 
 // --------------------------------------------------------------------------
@@ -238,5 +239,5 @@
 TDatime MTime::GetRootDatime() const
 {
-    return TDatime((UInt_t)((GetMjd()-40587)*kDay/1000));
+    return TDatime((UInt_t)((GetMjd()-40587)*kDaySec));
 }
 
@@ -252,5 +253,5 @@
 Double_t MTime::GetAxisTime() const
 {
-    return (GetMjd()-49718)*kDay/1000;
+    return (GetMjd()-49718)*kDaySec;
 }
 
@@ -261,14 +262,29 @@
 void MTime::SetAxisTime(Double_t time)
 {
-    SetMjd(time*1000/kDay+49718);
-}
-
-// --------------------------------------------------------------------------
-//
-// Set unix time (seconds since epoche 1970-01-01)
-//
-void MTime::SetUnixTime(Long_t tm)
-{
-    SetMjd(1000.*tm/kDay+40587);
+    SetMjd(time/kDaySec+49718);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set unix time (seconds since epoche 1970-01-01 00:00)
+//
+void MTime::SetUnixTime(Long64_t sec, ULong64_t usec)
+{
+    const Long64_t totsec = sec + usec/1000000;
+    const UInt_t   mjd    = totsec/kDaySec + 40587;
+
+    const UInt_t   ms     = totsec%kDaySec*1000 + (usec/1000)%1000;
+    const UInt_t   us     = usec%1000;
+
+    SetMjd(mjd, ms, us*1000);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set MTime to time expressed in a 'struct timeval'
+//
+void MTime::Set(const struct timeval &tv)
+{
+    SetUnixTime(tv.tv_sec, tv.tv_usec);
 }
 
@@ -342,18 +358,4 @@
 
     return SetMjd(mjd, tm, ns);
-}
-
-// --------------------------------------------------------------------------
-//
-// Set MTime to time expressed in a 'struct timeval'
-//
-void MTime::Set(const struct timeval &tv)
-{
-    const UInt_t mjd = (UInt_t)TMath::Floor(1000.*tv.tv_sec/kDay) + 40587;
-
-    const Long_t tm  = tv.tv_sec%(24*3600)*1000 + tv.tv_usec/1000;
-    const UInt_t ms  = tv.tv_usec%1000;
-
-    SetMjd(mjd, tm, ms*1000);
 }
 
@@ -489,5 +491,5 @@
     const Double_t r2 = 86400.0*ut;
 
-    const Double_t sum = (r1+r2)/(24*3600);
+    const Double_t sum = (r1+r2)/kDaySec;
 
     return fmod(sum, 1)*TMath::TwoPi();//+TMath::TwoPi();
@@ -975,5 +977,5 @@
 void MTime::SetMean(Double_t t0, Double_t t1)
 {
-    const Double_t mean = (t0+t1)*(500./kDay);
+    const Double_t mean = (t0+t1)*(0.5/kDaySec);
     SetMjd(mean);
 }
Index: trunk/MagicSoft/Mars/mbase/MTime.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8544)
+++ trunk/MagicSoft/Mars/mbase/MTime.h	(revision 8551)
@@ -27,6 +27,7 @@
 {
 public:
-    static const UInt_t kHour; // [ms] one hour
-    static const UInt_t kDay;  // [ms] one day
+    static const UInt_t kHour;    // [ms] one hour
+    static const UInt_t kDay;     // [ms] one day
+    static const UInt_t kDaySec;  // [s] one day
 
     enum {
@@ -98,5 +99,5 @@
     void     SetMjd(Double_t m);
     void     SetAxisTime(Double_t time);
-    void     SetUnixTime(Long_t time);
+    void     SetUnixTime(Long64_t sec, ULong64_t usec=0);
     void     SetEaster(Short_t year=0);
 
@@ -126,14 +127,17 @@
     }
 
-    UInt_t Year() const    { UShort_t y; Byte_t m, d; GetDate(y,m,d); return y; }
-    UInt_t Month() const   { UShort_t y; Byte_t m, d; GetDate(y,m,d); return m; }
-    UInt_t Day() const     { UShort_t y; Byte_t m, d; GetDate(y,m,d); return d; }
-    Byte_t WeekDay() const { return TMath::Nint(TMath::Floor(GetMjd()+3))%7; } // Return Day of the week: Sun=0, Mon=1, ..., Sat=6
-    UInt_t Hour() const    { Byte_t h, m, s; GetTime(h,m,s); return h; }
-    UInt_t Min() const     { Byte_t h, m, s; GetTime(h,m,s); return m; }
-    UInt_t Sec() const     { Byte_t h, m, s; GetTime(h,m,s); return s; }
+    UInt_t Year() const     { UShort_t y; Byte_t m, d; GetDate(y,m,d); return y; }
+    UInt_t Month() const    { UShort_t y; Byte_t m, d; GetDate(y,m,d); return m; }
+    UInt_t Day() const      { UShort_t y; Byte_t m, d; GetDate(y,m,d); return d; }
+    Byte_t WeekDay() const  { return TMath::Nint(TMath::Floor(GetMjd()+3))%7; } // Return Day of the week: Sun=0, Mon=1, ..., Sat=6
+    UInt_t Hour() const     { Byte_t h, m, s; GetTime(h,m,s); return h; }
+    UInt_t Min() const      { Byte_t h, m, s; GetTime(h,m,s); return m; }
+    UInt_t Sec() const      { Byte_t h, m, s; GetTime(h,m,s); return s; }
+    UInt_t MilliSec() const { return (GetTime()+kDay)%1000; }
+    UInt_t MicroSec() const { return fNanoSec/1000+MilliSec()*1000; }
+    UInt_t NanoSec() const  { return fNanoSec+MilliSec()*1000000; }
+    Int_t  Week() const     { Short_t y; return Week(y); }
+    Int_t  Week(Short_t &year) const;
     UInt_t DayOfYear() const;
-    Int_t  Week() const    { Short_t y; return Week(y); }
-    Int_t  Week(Short_t &year) const;
 
     Bool_t IsMidnight() const { return (Long_t)fTime==0 && fNanoSec==0; }
