Archived Forum Post

Index of archived forum posts

Question:

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;
ckdt1.SetFromTimestamp("2016-01-01T12:00:00Z");
ckdt2.SetFromTimestamp("2017-01-01T12:00:00Z");
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 9.5.0.68 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.


Answer

Thanks, I'll have a look..


Answer

This new build should fix it:

https://chilkatdownload.com/prerelease/chilkat-9.5.0-x86-vc12_xp.zip
https://chilkatdownload.com/prerelease/chilkat-9.5.0-x86_64-vc12_xp.zip