From 3e81a7442d2e3e6fcc7d6ad2f4f4b7960dd09ecf Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Sun, 7 Jul 2002 13:17:23 +0000 Subject: - Added comparison operators in PsiTime - Fixed a typo --- lib/psitime.cc | 22 ++++++++++++++++++++++ lib/psitime.h | 7 +++++++ lib/sisfileheader.cpp | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/psitime.cc b/lib/psitime.cc index 213858d..da96bb3 100644 --- a/lib/psitime.cc +++ b/lib/psitime.cc @@ -153,6 +153,28 @@ PsiTime &PsiTime::operator=(const PsiTime &t) { return *this; } +bool PsiTime::operator==(const PsiTime &t) { + psi2unix(); + return ((utv.tv_sec == t.utv.tv_sec) && + (utv.tv_usec == t.utv.tv_usec)); +} + +bool PsiTime::operator<(const PsiTime &t) { + psi2unix(); + if (utv.tv_sec == t.utv.tv_sec) + return (utv.tv_usec < t.utv.tv_usec); + else + return (utv.tv_sec < t.utv.tv_sec); +} + +bool PsiTime::operator>(const PsiTime &t) { + psi2unix(); + if (utv.tv_sec == t.utv.tv_sec) + return (utv.tv_usec > t.utv.tv_usec); + else + return (utv.tv_sec > t.utv.tv_sec); +} + ostream &operator<<(ostream &s, const PsiTime &t) { const char *fmt = "%c"; char buf[100]; diff --git a/lib/psitime.h b/lib/psitime.h index 605d531..7732783 100644 --- a/lib/psitime.h +++ b/lib/psitime.h @@ -298,6 +298,13 @@ public: */ PsiTime &operator=(const PsiTime &t); + /** + * Comparison operators + */ + bool operator==(const PsiTime &t); + bool operator<(const PsiTime &t); + bool operator>(const PsiTime &t); + enum zone { PSI_TZ_NONE = 0, PSI_TZ_EUROPEAN = 1, diff --git a/lib/sisfileheader.cpp b/lib/sisfileheader.cpp index c816c00..e15e54b 100644 --- a/lib/sisfileheader.cpp +++ b/lib/sisfileheader.cpp @@ -114,7 +114,7 @@ SISFileHeader::fillFrom(uint8_t* buf, int* base, off_t len) printf(_("Got options: %04x\n"), m_options); m_type = read16(start + 38); if (logLevel >= 2) - printf(_("Got type: %0x\n"), m_type); + printf(_("Got type: %04x\n"), m_type); m_major = read16(start + 40); if (logLevel >= 2) printf(_("Got major: %d\n"), m_major); -- cgit v1.2.3