-
-
Save anonymous/d6b7654bdfce13e97e7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct STimeStamp | |
{ | |
/** Default (empty) constructor */ | |
STimeStamp() : Days(0), Secs(0), USecs(0) {} | |
/** Copy constructor | |
@param _obj Time Stamp to be copied */ | |
STimeStamp(const STimeStamp& _obj) : Days(_obj.Days), Secs(_obj.Secs), USecs(_obj.USecs) {} | |
/** Returns true if time stamp is set to any value (<b>Not</b> to reasonable one)*/ | |
bool isValid(void) { return !(Days==0 && Secs==0 && USecs==0); } | |
/** normalize time stamp. | |
This method sets all fields in time stamp to proper range */ | |
void normalize() { | |
while (USecs > 1e6) { | |
Secs++; | |
USecs = (unsigned)(USecs - 1e6); | |
} | |
while (Secs > 86400) { | |
Days++; | |
Secs = (unsigned)(Secs - 86400); | |
} | |
} | |
/** Reset time stamp to improper value */ | |
void reset(void) { Days=0; Secs=0; USecs=0; } | |
/** Date */ | |
unsigned Days; | |
/** Time - seconds */ | |
unsigned Secs; | |
/** Time - useconds */ | |
unsigned USecs; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment