#pragma once #include #include "data/Data.h" /* * 日期时间数据类型 * * */ class DateTimeData : public Data { public: DateTimeData(); DateTimeData(unsigned short year, unsigned char month, unsigned char day, unsigned char hour, unsigned char minute, unsigned char second); virtual ~DateTimeData() {}; Data* clone() override; void copy(Data* data) override; void copy(Data& data) override; int length() override { return 7; } std::string toStr() override; std::string toByteStr() override; std::string toHexStr() override; bool fromByteStr(std::string str = "") override; unsigned short getYear() { return m_year; } unsigned char getMonth() { return m_month; } unsigned char getDay() { return m_day; } unsigned char getHour() { return m_hour; } unsigned char getMinute() { return m_minute; } unsigned char getSecond() { return m_second; } void setYear(unsigned short year) { m_year = year; } void setMonth(unsigned char month) { m_month = month; } void setDay(unsigned char day) { m_day = day; } void setHour(unsigned char hour) { m_hour = hour; } void setMinute(unsigned char minute) { m_minute = minute; } void setSecond(unsigned char second) { m_second = second; } private: unsigned short m_year; unsigned char m_month; unsigned char m_day; unsigned char m_hour; unsigned char m_minute; unsigned char m_second; };