Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:22

0001 // name=stamp32 ; gcc $name.cc -std=c++11 -lstdc++ -o /tmp/$name && /tmp/$name
0002 
0003 /**
0004 Datetime corresponding to UINT32_MAX: Thu Jan  1 02:11:34 1970
0005 
0006 
0007 Persisting stamps with 32 bits is not practical. 
0008 **/
0009 
0010 #include <iostream>
0011 #include <chrono>
0012 #include <ctime>
0013 
0014 int main() {
0015     // Calculate the datetime corresponding to UINT32_MAX
0016     std::chrono::system_clock::time_point epochTime;
0017     std::chrono::system_clock::duration durationSinceEpoch = std::chrono::microseconds(UINT32_MAX);
0018     std::chrono::system_clock::time_point maxTime = epochTime + durationSinceEpoch;
0019 
0020     // Convert the time point to a C-style time
0021     std::time_t maxTimeT = std::chrono::system_clock::to_time_t(maxTime);
0022 
0023     // Convert to a string representation
0024     std::string maxTimeStr = std::ctime(&maxTimeT);
0025 
0026     std::cout << "Datetime corresponding to UINT32_MAX: " << maxTimeStr;
0027 
0028     return 0;
0029 }
0030