#pragma once #include #include #include class Time_s; // Insert a time into an output stream. std::ostream &operator<<( std::ostream &out, Time_s const &time ); class Time_s { public: // Construct a non-negative time. Time_s( std::uint32_t const hours, unsigned int const minutes, unsigned int const seconds ); // Return if the time is negative, and // the hour, minute, and second components. bool negative() const; std::uint32_t hours() const; std::uint8_t minutes() const; std::uint8_t seconds() const; // Comparison of times bool operator==( Time_s const &other ) const; bool operator!=( Time_s const &other ) const; bool operator< ( Time_s const &other ) const; bool operator<=( Time_s const &other ) const; bool operator>=( Time_s const &other ) const; bool operator> ( Time_s const &other ) const; // Return this time or its additive inverse. Time_s operator+() const; Time_s operator-() const; // Add or subtract another time. Time_s operator+( Time_s const &other ) const; Time_s operator-( Time_s const &other ) const; // Add or subtract another time from this time. Time_s &operator+=( Time_s const &other ); Time_s &operator-=( Time_s const &other ); // Add or subtract a second from this time. Time_s &operator++(); Time_s operator++( int ); Time_s &operator--(); Time_s operator--( int ); // Return a string representation of this time. std::string to_string() const; private: std::int64_t seconds_; Time_s( std::int64_t const seconds ); };