Archived Forum Post

Index of archived forum posts


CkDateTime DiffSeconds returns 0 when negative is expected

Jun 13 '17 at 09:13

CkDateTime::DiffSeconds returns 0 when it should have returned a negative value (according to the documentation):

CkDateTime ckdt1, ckdt2;
auto nSeconds1 = ckdt1.DiffSeconds(ckdt2); // nSeconds1 = 0
auto nSeconds2 = ckdt2.DiffSeconds(ckdt1); // nSeconds2 = 31622400

ckdt1 is obviously older than ckdt2, but does not return -31622400 as expected. No error is returned and put_VerboseLogging/put_DebugLogFilePath/lastErrorText does not indicate any issues.

This has been tested with version of Chilkat C/C++ Libs for VC++ 12.0 XP / win32.

By the way I am missing a simple method to compare dates. Maybe DiffSeconds was meant for that purpose, but counting the exact difference ought to be slower than to simply determine which is newer/older/equal.

Accepted Answer

I made the fix, but can't produce a new build until late today or tomorrow. I'll post it here.

PS> DiffSeconds is valid for comparing dates. It's not slower than if a method returned true/false.


Thanks, I'll have a look..


This new build should fix it: