Processing time in c/c++ — solution for year 2038 problem in 32 bit machine

tm start_parsed = {};
strptime("2020-01-21 05:00", "%Y-%m-%d %H:%M", &start_parsed)
tm end_parsed = {};
strptime("2038-12-23 05:00", "%Y-%m-%d %H:%M", &end_parsed)
time_t start = mktime(&start_parsed);
time_t end = mktime(&end_parsed);
int dates = difftime(end, start) / (60 * 60 * 24);
1. Download the library from the github repo
2. Copy/paste the files time64.c, time64.h, time64_config.h, time64_limits.h into our project
3. Uncomment the line #define USE_TM64 in the file time64_config.h
4. Include the file #include "time64.h"
tm start_parsed = {};
strptime("2020-01-21 05:00", "%Y-%m-%d %H:%M", &start_parsed)
TM start_parsed64 = {};
start_parsed64.tm_year = start_parsed.tm_year;
start_parsed64.tm_mon = start_parsed.tm_mon;
start_parsed64.tm_mday = start_parsed.tm_mday;
tm end_parsed = {};
strptime("2038-12-23 05:00", "%Y-%m-%d %H:%M", &end_parsed)
TM end_parsed64 = {};
end_parsed64.tm_year = end_parsed.tm_year;
end_parsed64.tm_mon = end_parsed.tm_mon;
end_parsed64.tm_mday = end_parsed.tm_mday;
int dates = diff_dates(end_parsed64, start_parsed64)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store