TpDate 类
V0.2.1TpUtils
2025-11-14
介绍
日期类,提供日期相关操作
基础信息
| 头文件: | include <TpDate.h> |
|---|---|
| Cmake: | None |
| 发布版本: | V0.2.1 |
| 继承类: | |
| 派生类: |
Public 成员函数
| TpDate() | ||
|---|---|---|
| TpDate(const int32_t &y, const int32_t &m, const int32_t &d) | ||
| ~TpDate() | ||
| year() const | 获取日期的年份 | |
| month() const | 获取日期的月份 | |
| day() const | 获取日期的天 | |
| setYear(const int32_t &year) | 设置年份 | |
| setMonth(const int32_t &month) | 设置月份 | |
| setDay(const int32_t &day) | 设置日期 | |
| dayOfWeek() const | 获取日期是当周的第几天 | |
| dayOfYear() const | 获取当前日期在该年中的天数 | |
| daysInMonth() const | 获取当前日期所在月份的天数 | |
| daysInYear() const | 返回当前日期所在年份共计多少天 | |
| TpDate TpDate::addDays | addDays(const int64_t &days) const | 基于当前日期添加指定天数 |
| TpDate TpDate::addMonths | addMonths(const int32_t &months) const | 基于当前日期添加指定月数 |
| TpDate TpDate::addYears | addYears(const int32_t &years) const | 基于当前日期添加指定年数 |
| TpString | toString(const TpString &format) const | 将日期对象转换为字符串 |
| toJulianDay() const | 转换为儒略日 | |
| TpDate & TpDate::operator= | operator=(const TpDate &other) noexcept | |
| operator==(const TpDate &other) const | ||
| operator<(const TpDate &other) const | ||
| operator!=(const TpDate &other) const | ||
| operator<=(const TpDate &other) const | ||
| operator>(const TpDate &other) const | ||
| operator>=(const TpDate &other) const | ||
| static TpDate TpDate::fromString | fromString(const TpString &s, const TpString &format) | 将日期字符串转换日期对象 |
| static TpDate TpDate::currentDate | currentDate() | 获取当前日期 |
成员函数说明
TpDate::TpDate()
暂无注释...
TpDate::TpDate(const int32_t &y, const int32_t &m, const int32_t &d)
暂无注释...
TpDate::~TpDate()
暂无注释...
int32_t TpDate::year() const
获取日期的年份...
获取日期的年份
返回值:年份
int32_t TpDate::month() const
获取日期的月份...
获取日期的月份
返回值:月份
int32_t TpDate::day() const
获取日期的天...
获取日期的天
返回值:天数
void TpDate::setYear(const int32_t &year)
设置年份...
设置年份
参数:year: 年份
void TpDate::setMonth(const int32_t &month)
设置月份...
设置月份
参数:month: 月份
void TpDate::setDay(const int32_t &day)
设置日期...
设置日期
参数:day: 日期
int32_t TpDate::dayOfWeek() const
获取日期是当周的第几天...
获取日期是当周的第几天
返回值:当周的第几天,1为星期一,7为星期日
int32_t TpDate::dayOfYear() const
获取当前日期在该年中的天数...
获取当前日期在该年中的天数
返回值:当年的第几天
int32_t TpDate::daysInMonth() const
获取当前日期所在月份的天数...
获取当前日期所在月份的天数
返回值:当月有多少天
int32_t TpDate::daysInYear() const
返回当前日期所在年份共计多少天...
返回当前日期所在年份共计多少天
返回值:天数365;366
TpDate TpDate::addDays(const int64_t &days) const
基于当前日期添加指定天数...
基于当前日期添加指定天数
参数:days: 添加天数
返回值:返回叠加后的新日期对象
TpDate TpDate::addMonths(const int32_t &months) const
基于当前日期添加指定月数...
基于当前日期添加指定月数
参数:months: 添加月数
返回值:返回叠加后的新日期对象
TpDate TpDate::addYears(const int32_t &years) const
基于当前日期添加指定年数...
基于当前日期添加指定年数
参数:years: 添加年数
返回值:返回叠加后的新日期对象
TpString TpDate::toString(const TpString &format) const
将日期对象转换为字符串...
将日期对象转换为字符串
参数:format: 格式化字符串 例如yyyy-MM-dd
返回值:日期对象
int64_t TpDate::toJulianDay() const
转换为儒略日...
转换为儒略日
返回值:儒略日
TpDate & TpDate::operator=(const TpDate &other) noexcept
暂无注释...
bool TpDate::operator==(const TpDate &other) const
暂无注释...
bool TpDate::operator<(const TpDate &other) const
暂无注释...
bool TpDate::operator!=(const TpDate &other) const
暂无注释...
bool TpDate::operator<=(const TpDate &other) const
暂无注释...
bool TpDate::operator>(const TpDate &other) const
暂无注释...
bool TpDate::operator>=(const TpDate &other) const
暂无注释...
static TpDate TpDate::fromString(const TpString &s, const TpString &format)
将日期字符串转换日期对象...
将日期字符串转换日期对象
参数:s: 日期字符串
参数:format: 格式化字符串 例如yyyy-MM-dd
返回值:tpDate对象
static TpDate TpDate::currentDate()
获取当前日期...
获取当前日期
返回值:当前日期对象
