summaryrefslogtreecommitdiff
path: root/include/iprt/time.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/iprt/time.h')
-rw-r--r--include/iprt/time.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/iprt/time.h b/include/iprt/time.h
index 2981d9de6bd..a0021baf82e 100644
--- a/include/iprt/time.h
+++ b/include/iprt/time.h
@@ -513,6 +513,23 @@ DECLINLINE(bool) RTTimeSpecIsEqual(PCRTTIMESPEC pTime1, PCRTTIMESPEC pTime2)
return pTime1->i64NanosecondsRelativeToUnixEpoch == pTime2->i64NanosecondsRelativeToUnixEpoch;
}
+
+/**
+ * Compare two time specs.
+ *
+ * @returns 0 if equal, -1 if @a pLeft is smaller, 1 if @a pLeft is larger.
+ * @returns false they are not equal.
+ * @param pLeft The 1st time spec.
+ * @param pRight The 2nd time spec.
+ */
+DECLINLINE(int) RTTimeSpecCompare(PCRTTIMESPEC pLeft, PCRTTIMESPEC pRight)
+{
+ if (pLeft->i64NanosecondsRelativeToUnixEpoch == pRight->i64NanosecondsRelativeToUnixEpoch)
+ return 0;
+ return pLeft->i64NanosecondsRelativeToUnixEpoch < pRight->i64NanosecondsRelativeToUnixEpoch ? -1 : 1;
+}
+
+
/**
* Converts a time spec to a ISO date string.
*