25 static DateTimeL FromSecond( time_t second );
29 static DateTimeL FromTm(
struct tm
const * t );
34 explicit Second( time_t second ) : value(second)
49 DateTimeL(
short year,
short month,
short day,
short hour,
short minute,
short second,
short millisec = 0 );
62 short getDay()
const {
return _day; }
77 void setYear(
short year ) { _year = year; }
79 void setMonth(
short month ) { _month = month; }
81 void setDay(
short day ) { _day = day; }
83 void setHour(
short hour ) { _hour = hour; }
85 void setMinute(
short minute ) { _minute = minute; }
87 void setSecond(
short second ) { _second = second; }
92 time_t toUtcTime()
const;
94 uint64 toUtcTimeMs()
const;
96 template <
typename _ChTy >
102 #if defined(_UNICODE) || defined(UNICODE) 110 #if defined(_UNICODE) || defined(UNICODE) 111 typename _ChTy =
wchar 113 typename _ChTy =
char 120 #if defined(_UNICODE) || defined(UNICODE) 121 typename _ChTy =
wchar 123 typename _ChTy =
char 131 DateTimeL & fromTm(
struct tm
const * t );
150 #if defined(_UNICODE) || defined(UNICODE) 180 #endif // __TIME_HPP__ 本地日期时间。L意思'local',不包含时区信息
void setHour(short hour)
设置时[0~23]
static ulong GetSecondsFromMinutes(int minutes)
获取几分钟是多少秒
void setMonth(short month)
设置月[1~12]
MilliSec(uint64 millisec)
short getDayOfYear() const
年第几日[1~366, 1=01-01]
void setDay(short day)
设置日[1~31]
std::ostream & operator<<(std::ostream &out, ConsoleAttrT< _VarType > const &tr)
XString< _ChTy > toString() const
转为时间串
static ulong GetSecondsFromWeeks(int weeks)
获取几周是多少秒
std::basic_string< _ChTy, std::char_traits< _ChTy >, std::allocator< _ChTy > > XString
time_t GetUtcTime(void)
获取UTC时间秒数,或者调用CRT的time(NULL)
short getHour() const
时[0~23]
void setSecond(short second)
设置秒[0~59]
XString< _ChTy > format(XString< _ChTy > const &fmt) const
#define WINUX_FUNC_DECL(ret)
short getSecond() const
秒[0~59]
uint64 GetUtcTimeMs(void)
获取UTC时间毫秒数,UTC秒数可以直接除以1000,或者调用CRT的time(NULL)
short getMonth() const
月[1~12]
short getYear() const
年[1~2038]
uint64 GetUtcTimeUs(void)
获取UTC时间微秒数,UTC秒数可以直接除以1000000,或者调用CRT的time(NULL)
short getMillisec() const
毫秒[0~999]
static ulong GetSecondsFromHours(int hours)
获取几小时是多少秒
static ulong GetSecondsFromDays(int days)
获取几天是多少秒
short getDayOfWeek() const
星期几[0~6, 0=Sunday]
void setMillisec(short millisec)
设置毫秒[0~999]
void setMinute(short minute)
设置分[0~59]
short getMinute() const
分[0~59]
short getDay() const
日[1~31]
XString< _ChTy > toGmtString() const
转为GMT时间串,可用在HTTP头里
void setYear(short year)
设置年[1~2038]