Mercurial > minori
comparison src/core/time.cc @ 188:168382a89b21
time: static assert time_t
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Wed, 06 Dec 2023 13:44:36 -0500 |
| parents | 9b2b41f83a5e |
| children | 7cf53145de11 |
comparison
equal
deleted
inserted
replaced
| 187:9613d72b097e | 188:168382a89b21 |
|---|---|
| 54 int64_t Duration::InDays() { | 54 int64_t Duration::InDays() { |
| 55 return std::llround(static_cast<double>(length) / 86400.0); | 55 return std::llround(static_cast<double>(length) / 86400.0); |
| 56 } | 56 } |
| 57 | 57 |
| 58 int64_t GetSystemTime() { | 58 int64_t GetSystemTime() { |
| 59 assert(sizeof(int64_t) >= sizeof(time_t)); | 59 static_assert(sizeof(int64_t) >= sizeof(time_t)); |
| 60 time_t t = std::time(nullptr); | 60 time_t t = std::time(nullptr); |
| 61 return *reinterpret_cast<int64_t*>(&t); | 61 return *reinterpret_cast<int64_t*>(&t); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace Time | 64 } // namespace Time |
