xref: /openbmc/telemetry/src/utils/clock.hpp (revision 51f0fd50)
1 #pragma once
2 
3 #include "interfaces/clock.hpp"
4 #include "types/duration_types.hpp"
5 
6 #include <chrono>
7 
8 class Clock : public interfaces::Clock
9 {
10   public:
steadyTimestamp() const11     Milliseconds steadyTimestamp() const noexcept override
12     {
13         return std::chrono::time_point_cast<Milliseconds>(
14                    std::chrono::steady_clock::now())
15             .time_since_epoch();
16     }
17 
systemTimestamp() const18     Milliseconds systemTimestamp() const noexcept override
19     {
20         return std::chrono::time_point_cast<Milliseconds>(
21                    std::chrono::system_clock::now())
22             .time_since_epoch();
23     }
24 };
25