Chip8-CPP/include/date.h

36 lines
753 B
C++

#ifndef CHIP8_DATE_H
#define CHIP8_DATE_H
#include <chrono>
/**
* Class used to work with dates and times
*/
class Date {
public:
/**
* Creates a new Date object with the given time_point
* @param tp the time_point object
*/
explicit Date(std::chrono::system_clock::time_point tp);
/**
* Gets a Date object with the current time as time_point
* @return The Date object
*/
static Date now();
/**
* Converts the time_point to a string with format "Y-%m-%d %H:%M:%S"
* @return the formatted datetime string
*/
[[nodiscard]] std::string to_string() const;
private:
/**
* The time_point to use
*/
std::chrono::system_clock::time_point tp;
};
#endif //CHIP8_DATE_H