From ef5d6a475dcfbe612562a4c3ef17e5a5588d3b28 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 30 Apr 1999 00:02:02 +0000 Subject: [PATCH] added getCurrentEPICS() --- src/libCom/osiTime.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/libCom/osiTime.h b/src/libCom/osiTime.h index ee8c49ce8..82d230a95 100644 --- a/src/libCom/osiTime.h +++ b/src/libCom/osiTime.h @@ -29,6 +29,9 @@ * * History * $Log$ + * Revision 1.6 1997/06/13 09:31:46 jhill + * fixed warnings + * * Revision 1.5 1997/04/10 19:45:41 jhill * API changes and include with not <> * @@ -161,6 +164,22 @@ public: static osiTime getCurrent(); + // + // return time stamp with EPICS epoch + // + static osiTime getCurrentEPICS() + { + // + // 1/1/90 20 yr (5 leap) of seconds + // + static const unsigned epicsEpochSecPast1970 = 7305 * 86400; + + osiTime ts(osiTime::getCurrent()); + assert (ts.sec>=epicsEpochSecPast1970); + ts.sec -= epicsEpochSecPast1970; + return ts; + } + osiTime operator+= (const osiTime &rhs); osiTime operator-= (const osiTime &rhs); @@ -197,7 +216,7 @@ inline osiTime operator- (const osiTime &lhs, const osiTime &rhs) // // wrap around // - sec = lhs.sec + (ULONG_MAX - rhs.sec); + sec = 1 + lhs.sec + (ULONG_MAX - rhs.sec); } else { sec = lhs.sec - rhs.sec; @@ -207,7 +226,7 @@ inline osiTime operator- (const osiTime &lhs, const osiTime &rhs) // // Borrow // - nSec = lhs.nSec + (nSecPerSec - rhs.nSec); + nSec = 1 + lhs.nSec + (nSecPerSec - rhs.nSec); sec--; } else {