Conversation
|
No objections to use |
|
For daysElapsed()? Because POSIX time_t may be unsigned (as it is on my platform) so it cannot be used when the return value could be negative. For a result in days, it didn't seem to me like it was worth explicitly overriding the system default width -- a 32-bit day count spans a range of about 5.8 million years. If that's not enough I can resubmit with int64_t. |
|
We do not seem to use |
On platforms with unsigned time_t simple subtraction may produce a large positive result instead of the expected negative value. Use difftime() to ensure meaningful comparison.
|
Updated. I've broken the changes down in to two commits (one for difftime, one for daysElapsed) for clarity. |
|
Merging, thanks for the contribution! |
On platforms with unsigned time_t simple subtraction may produce a large positive result instead of the expected negative value. Use difftime() instead of subtracting to ensure meaningful comparisons.
I ran in to this issue using logrotate on QNX 6.6. It may be the only POSIX-compliant platform in any use today with an unsigned time_t, so this fix may not be worth the churn, but I thought I'd offer it anyhow.