From ebb2d9d1860ae5f8893526db5c57405524d16958 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Thu, 16 Jun 2022 17:06:05 -0600 Subject: [PATCH] Implement `sf::Time` with `` --- include/SFML/System/Time.hpp | 4 +++- include/SFML/System/Time.inl | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 79bc3c760..bfe9dc888 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 39fdb5ce1..ed26cac39 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(); }