TpTime 类
V0.2.1TpUtils
2025-11-14
介绍
时间类,提供时间相关操作
基础信息
| 头文件: | include <TpTime.h> |
|---|---|
| Cmake: | None |
| 发布版本: | V0.2.1 |
| 继承类: | |
| 派生类: |
Public 成员函数
| TpTime() | ||
|---|---|---|
| TpTime(int32_t h, int32_t m, int32_t s, int32_t ms=0) | ||
| ~TpTime() | ||
| hour() const | 获取时间小时值 | |
| minute() const | 获取时间分钟值 | |
| second() const | 获取时间秒值 | |
| msec() const | 获取时间毫秒值 | |
| TpString | toString(const TpString &format) const | 将时间对象转换为字符串 |
| setHMS(int32_t h, int32_t m, int32_t s, int32_t ms=0) | 设置时间的时分秒毫秒 | |
| TpTime TpTime::addSecs | addSecs(int32_t secs) const | 对当前时间添加指定秒数 |
| secsTo(const TpTime &t) const | 从当前时间到指定时间的时间间隔 秒 | |
| TpTime TpTime::addMSecs | addMSecs(int64_t ms) const | 对当前时间添加指定毫秒数 |
| msecsTo(const TpTime &t) const | 从当前时间到指定时间的时间间隔 毫秒 | |
| TpTime & TpTime::operator= | operator=(const TpTime &other) noexcept | |
| operator==(const TpTime &other) const | ||
| operator<(const TpTime &other) const | ||
| operator!=(const TpTime &other) const | ||
| operator<=(const TpTime &other) const | ||
| operator>(const TpTime &other) const | ||
| operator>=(const TpTime &other) const | ||
| static TpTime TpTime::currentTime | currentTime() | 获取当前时间 |
| static TpTime TpTime::fromString | fromString(const TpString &s, const TpString &format) | 将时间字符串转换为时间对象 |
成员函数说明
TpTime::TpTime()
暂无注释...
TpTime::TpTime(int32_t h, int32_t m, int32_t s, int32_t ms=0)
暂无注释...
TpTime::~TpTime()
暂无注释...
int32_t TpTime::hour() const
获取时间小时值...
获取时间小时值
返回值:小时
int32_t TpTime::minute() const
获取时间分钟值...
获取时间分钟值
返回值:分钟
int32_t TpTime::second() const
获取时间秒值...
获取时间秒值
返回值:秒
int32_t TpTime::msec() const
获取时间毫秒值...
获取时间毫秒值
返回值:毫秒
TpString TpTime::toString(const TpString &format) const
将时间对象转换为字符串...
将时间对象转换为字符串
参数:format: 格式化字符串 例如"HH:mm"
返回值:时间字符串
bool TpTime::setHMS(int32_t h, int32_t m, int32_t s, int32_t ms=0)
设置时间的时分秒毫秒...
设置时间的时分秒毫秒
参数:h: 小时
参数:m: 分钟
参数:s: 秒
参数:ms: 毫秒
返回值:返回设置结果;如果时间取值错误,则返回false
TpTime TpTime::addSecs(int32_t secs) const
对当前时间添加指定秒数...
对当前时间添加指定秒数
参数:secs: 秒数
返回值:返回添加指定秒数后的事件对象
int32_t TpTime::secsTo(const TpTime &t) const
从当前时间到指定时间的时间间隔 秒...
从当前时间到指定时间的时间间隔 秒
参数:t: 指定时间
返回值:指定时间在当前时间之后为正,反之为负值
TpTime TpTime::addMSecs(int64_t ms) const
对当前时间添加指定毫秒数...
对当前时间添加指定毫秒数
参数:ms: 毫秒数
返回值:返回添加指定毫秒数后的事件对象
int64_t TpTime::msecsTo(const TpTime &t) const
从当前时间到指定时间的时间间隔 毫秒...
从当前时间到指定时间的时间间隔 毫秒
参数:t: 指定时间
返回值:指定时间在当前时间之后为正,反之为负值
TpTime & TpTime::operator=(const TpTime &other) noexcept
暂无注释...
bool TpTime::operator==(const TpTime &other) const
暂无注释...
bool TpTime::operator<(const TpTime &other) const
暂无注释...
bool TpTime::operator!=(const TpTime &other) const
暂无注释...
bool TpTime::operator<=(const TpTime &other) const
暂无注释...
bool TpTime::operator>(const TpTime &other) const
暂无注释...
bool TpTime::operator>=(const TpTime &other) const
暂无注释...
static TpTime TpTime::currentTime()
获取当前时间...
获取当前时间
返回值:事件对象
static TpTime TpTime::fromString(const TpString &s, const TpString &format)
将时间字符串转换为时间对象...
将时间字符串转换为时间对象
参数:s: 时间字符串
参数:format: 格式化字符串 例如HH:mm
返回值:时间对象
