Advertisement
kijato

OLETIME to ...time...

Feb 22nd, 2025 (edited)
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. #include <cstdint>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     vector<uint8_t> bytes = { 190, 110, 116, 207, 178, 140, 229, 64 };
  11.     int64_t l = 0;
  12.  
  13.     for (size_t i = 0; i < bytes.size(); ++i) {
  14.         l |= static_cast<int64_t>(bytes[i]) << (i * 8);
  15.     }
  16.  
  17.     double d = *reinterpret_cast<double*>(&l);
  18.     time_t t = static_cast<time_t>(d);
  19.     tm* dt = localtime(&t);
  20.  
  21.     //cout << put_time(dt, "%Y-%m-%d %H:%M:%S") << endl;
  22.     cout << dt << endl;
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement