Files
BasicsOfComputerSoftwareEng…/FinalProject/Date.hpp
2023-06-24 17:31:16 +08:00

35 lines
928 B
C++

#pragma once
#include "Exceptions.hpp"
#include <ctime>
#include <string>
// Reference: https://cplusplus.com/reference/ctime
class Date {
private:
// The time stored.
time_t time;
// If this date represents "Any time".
bool _isAny;
public:
Date();
Date(const time_t &_time);
Date(const tm &_time);
// Set the stored date to the argument.
void setNewDate(const time_t &newTime);
void setNewDate(const tm &newTime);
// Set the date to "any".
void setAny();
// returns the time.
bool isAny() const;
time_t getTime() const;
// returns a human-readable string of the stored time.
std::string toString() const;
bool operator<(const Date &otherDate) const;
bool operator>(const Date &otherDate) const;
bool operator<=(const Date &otherDate) const;
bool operator>=(const Date &otherDate) const;
bool operator==(const Date &otherDate) const;
};