示例#1
0
        /// <summary>
        /// Get the time elapsed between tfrom and tto adjusted by multiplier and potentially rounded
        /// </summary>
        /// <param name="tfrom">start of time span definition</param>
        /// <param name="tto">end of timespan definition</param>
        /// <param name="multiplier">give 1000000 to get microseconds; 1.0/24/3600 to get days</param>
        /// <param name="round">Round to a whole number</param>
        /// <returns>adjusted time value</returns>
        public static double GetTimeStampValue(AgeReference tfrom, AgeReference tto, double multiplier, bool round)
        {
            var timeFrom = GetEpochTime(tfrom);
            var timeTo   = GetEpochTime(tto);
            var value    = AdjustTimeValue(timeTo - timeFrom, multiplier, round);

            return(value);
        }
示例#2
0
        /// <summary>
        /// Get the epoch time requested in seconds
        /// </summary>
        /// <param name="ageRef"></param>
        /// <returns>seconds since epoch 1970</returns>
        public static double GetEpochTime(AgeReference ageRef)
        {
            switch (ageRef)
            {
            case AgeReference.Now:
                var uptime = GetSystemUpTime();
                return(s_ref_sys_time + uptime);

            case AgeReference.Epoch1970: return(0);

            case AgeReference.SystemStart: return(s_ref_sys_time);

            case AgeReference.ApplicationStart: return(s_ref_app_time);

            default:
                LogLog.Error(typeof(Stamp), String.Format("AgeReference not implemented: {0}", ageRef));
                return(long.MinValue);
            }
        }
 /// <summary>
 /// Create instance by default stamping with Now - Epoch1970
 /// </summary>
 public TimeStamp()
 {
     TimeFrom = AgeReference.Epoch1970;
     TimeTo   = AgeReference.Now;
 }