.. index:: pair: class; EE::System::Time .. _doxid-class_e_e_1_1_system_1_1_time: class EE::System::Time ====================== .. toctree:: :hidden: Overview ~~~~~~~~ Represents a time value :ref:`EE::System::Time ` encapsulates a time value in a flexible way. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class Time { public: // fields static const Time :ref:`Zero`; // methods static bool :target:`isValid`(const std::string& str); static Time :target:`fromString`(const std::string& str); constexpr double :ref:`asSeconds`() const; constexpr double :ref:`asMilliseconds`() const; constexpr :ref:`Int64` :ref:`asMicroseconds`() const; std::string :ref:`toString`() const; }; .. _details-class_e_e_1_1_system_1_1_time: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Represents a time value :ref:`EE::System::Time ` encapsulates a time value in a flexible way. It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds. By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation. :ref:`Time ` values support the usual mathematical operations: you can add or subtract two times, multiply or divide a time by a number, compare two times, etc. Since they represent a time span and not an absolute time value, times can also be negative. Usage example: .. ref-code-block:: cpp Time t1 = Seconds(0.1f); double milli = t1.asMilliseconds(); // 100 Time t2 = Milliseconds(30); Int64 micro = t2.asMicroseconds(); // 30000 Time t3 = Microseconds(-800000); double sec = t3.asSeconds(); // -0.8 .. ref-code-block:: cpp void update(Time elapsed) { position += speed * elapsed; } update(Milliseconds(100)); .. rubric:: See also: :ref:`EE::System::Clock ` Fields ------ .. index:: pair: variable; Zero .. _doxid-class_e_e_1_1_system_1_1_time_1a495c78cf2e56b7aefe460d82ebfdee2a: .. ref-code-block:: cpp :class: doxyrest-title-code-block static const Time Zero Predefined "zero" time value. Methods ------- .. index:: pair: function; asSeconds .. _doxid-class_e_e_1_1_system_1_1_time_1ad3723528c931d29a2838c5460cac42db: .. ref-code-block:: cpp :class: doxyrest-title-code-block constexpr double asSeconds() const Return the time value as a number of seconds. .. rubric:: Returns: :ref:`Time ` in seconds .. rubric:: See also: AsMilliseconds, AsMicroseconds .. index:: pair: function; asMilliseconds .. _doxid-class_e_e_1_1_system_1_1_time_1abce2e9d349a4bdb5ef943d317b498cca: .. ref-code-block:: cpp :class: doxyrest-title-code-block constexpr double asMilliseconds() const Return the time value as a number of milliseconds. .. rubric:: Returns: :ref:`Time ` in milliseconds .. rubric:: See also: AsSeconds, AsMicroseconds .. index:: pair: function; asMicroseconds .. _doxid-class_e_e_1_1_system_1_1_time_1afec3910a5d2b0f490f1be265a96f9055: .. ref-code-block:: cpp :class: doxyrest-title-code-block constexpr :ref:`Int64` asMicroseconds() const Return the time value as a number of microseconds. .. rubric:: Returns: :ref:`Time ` in microseconds .. rubric:: See also: :ref:`asSeconds `, :ref:`asMilliseconds ` .. index:: pair: function; toString .. _doxid-class_e_e_1_1_system_1_1_time_1ab1ff79746c2b4ec043f452f047c077a9: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string toString() const Converts the time into a human readable string.