64-bit Unix timestamp conversion

后端 未结 5 1839
野趣味
野趣味 2020-12-16 18:00

Is there any C++ implementation of 64-bit Unix timestamp conversions for 32-bit systems? I need to convert struct tm to 64-bit integer and vice versa, including

5条回答
  •  死守一世寂寞
    2020-12-16 18:43

    You need:

    typedef long long time64_t; 
    time64_t mktime64(struct tm *t); 
    struct tm* localtime64_r(const time64_t* t, struct tm* p);
    

    Originally (in 2011) this answer contained links to 2038bug.com where it was possible to download the small pivotal_gmtime_r library, containing the mentioned functions. The library has been removed from 2038bug.com back then, the links became broken and were removed from the answer by a moderator. Seems like that pivotal_gmtime_r code can now be found here:

    https://github.com/franklin373/mortage/tree/master/time_pivotal

    Also, I've found another, more recent library, called y2038, that also implements mktime64 and localtime64_r:

    https://github.com/evalEmpire/y2038

提交回复
热议问题