I am migrating some code from vc120 to vc140 and I am running into a problem with ftime64. The problem is similar to one mentioned on the Visual Studio dev community where ftime64 seems to have a year-2038 bug in 2015/2017 but where 2013 does not.
Here's some example code:
#include "stdafx.h"
#include <sys/timeb.h>
int main()
{
__timeb64 testTime64;
_ftime64(&testTime64);
printf("%lld\n", testTime64.time);
return 0;
}
With dates after 03:14:07 UTC on 2038/01/19, the time appears to wrap over the 32-bit boundary.
To test, compile the above code as ftime_check and run the following from an admin command prompt (note your numbers will vary due to the time of day on your clock):
date 1/18/2038 && ftime_check
2147474668
date 1/20/2038 && ftime_check
-2147319812
For reference, here is the (expected) output as seen under vc120:
date 1/18/2038 && ftime_check
2147482944
date 1/20/2038 && ftime_check
2147655752
I see the same issue with all of these functions ftime, _ftime, _ftime64, _ftime_s, and _ftime64_s
Is anyone else experiencing this, and how are you working around it?