Lets say I have two
struct tm
I need to compare them in Linux, in Linux kernel and in Windows. What is the best way to make cross-platform check?
By "compare" I mean finding out what date is bigger. For example - I get date at this moment and compare it to date of some account expired.
You could convert them with mktime to time_t and then calculate difference with difftime:
time_t t1 = mktime(tm1);
time_t t2 = mktime(tm2);
double diffSecs = difftime(t1, t2); // If positive, then tm1 > tm2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With