Chip8-CPP/include/date.h

36 lines
753 B
C
Raw Normal View History

2023-09-09 17:57:57 +00:00
#ifndef CHIP8_DATE_H
#define CHIP8_DATE_H
#include <chrono>
/**
* Class used to work with dates and times
*/
2023-09-09 17:57:57 +00:00
class Date {
public:
/**
* Creates a new Date object with the given time_point
* @param tp the time_point object
*/
2023-09-09 17:57:57 +00:00
explicit Date(std::chrono::system_clock::time_point tp);
/**
* Gets a Date object with the current time as time_point
* @return The Date object
*/
2023-09-09 17:57:57 +00:00
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;
2023-09-09 17:57:57 +00:00
private:
/**
* The time_point to use
*/
2023-09-09 17:57:57 +00:00
std::chrono::system_clock::time_point tp;
};
#endif //CHIP8_DATE_H