diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 79bc3c76..bfe9dc88 100644 --- a/include/SFML/System/Time.hpp +++ b/include/SFML/System/Time.hpp @@ -30,6 +30,8 @@ //////////////////////////////////////////////////////////// #include +#include + namespace sf { @@ -103,7 +105,7 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - Int64 m_microseconds; //!< Time value stored as microseconds + std::chrono::microseconds m_microseconds; //!< Time value stored as microseconds }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Time.inl b/include/SFML/System/Time.inl index 39fdb5ce..ed26cac3 100644 --- a/include/SFML/System/Time.inl +++ b/include/SFML/System/Time.inl @@ -32,21 +32,21 @@ constexpr Time::Time() : m_microseconds(0) //////////////////////////////////////////////////////////// constexpr float Time::asSeconds() const { - return static_cast(static_cast(m_microseconds) / 1000000.0); + return std::chrono::duration(m_microseconds).count(); } //////////////////////////////////////////////////////////// constexpr Int32 Time::asMilliseconds() const { - return static_cast(m_microseconds / 1000); + return std::chrono::duration_cast>(m_microseconds).count(); } //////////////////////////////////////////////////////////// constexpr Int64 Time::asMicroseconds() const { - return m_microseconds; + return m_microseconds.count(); }