| 158 | } |
| 159 | |
| 160 | void duration_example3() |
| 161 | { |
| 162 | std::vector<uint8_t> input = { |
| 163 | 0xc7,0x0c,0xff, // timestamp 96 |
| 164 | 0x3b,0x9a,0xc9,0xff, // 999999999 nanoseconds in 32-bit unsigned int |
| 165 | 0xff,0xff,0xff,0xff,0x7c,0x55,0x81,0x7f // -2208988801 seconds in 64-bit signed int |
| 166 | }; |
| 167 | |
| 168 | auto milliseconds = msgpack::decode_msgpack<std::chrono::milliseconds>(input); |
| 169 | std::cout << "milliseconds elapsed since 1970-01-01 00:00:00 UTC: " << milliseconds.count() << "\n"; |
| 170 | |
| 171 | auto seconds = msgpack::decode_msgpack<std::chrono::seconds>(input); |
| 172 | std::cout << "seconds elapsed since 1970-01-01 00:00:00 UTC: " << seconds.count() << "\n"; |
| 173 | } |
| 174 | |
| 175 | int main() |
| 176 | { |