MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / duration_example3

Function duration_example3

examples/src/msgpack_examples.cpp:160–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160void 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
175int main()
176{

Callers 1

mainFunction · 0.85

Calls 1

countMethod · 0.45

Tested by

no test coverage detected