fastdo  0.5.12
time.hpp
浏览该文件的文档.
1 #ifndef __TIME_HPP__
2 #define __TIME_HPP__
3 
4 namespace winux
5 {
8 {
9 public:
10  DateTimeL();
11  DateTimeL( short year, short month, short day, short hour, short minute, short second, short millisec = 0 );
13  DateTimeL( ulong utcSecond );
15  DateTimeL( uint64 utcMillisec );
17  DateTimeL( String const & dateTimeStr );
18 
19  short getYear() const { return _year; }
20  short getMonth() const { return _month; }
21  short getDay() const { return _day; }
22  short getHour() const { return _hour; }
23  short getMinute() const { return _minute; }
24  short getSecond() const { return _second; }
25  short getMillisec() const { return _millisec; }
27  short getDayOfWeek() const { return _wday; }
29  short getDayOfYear() const { return _yday; }
30 
31  void setYear( short year ) { _year = year; }
32  void setMonth( short month ) { _month = month; }
33  void setDay( short day ) { _day = day; }
34  void setHour( short hour ) { _hour = hour; }
35  void setMinute( short minute ) { _minute = minute; }
36  void setSecond( short second ) { _second = second; }
37  void setMillisec( short millisec ) { _millisec = millisec; }
38 
39  ulong toUtcTime() const;
40  uint64 toUtcTimeMs() const;
41 
42  String toString() const;
44  DateTimeL & fromCurrent();
46  DateTimeL & fromTm( struct tm const * t );
47 
48  static ulong GetSecondsFromWeeks( int weeks ) { return weeks * 7UL * 86400UL; }
49  static ulong GetSecondsFromDays( int days ) { return days * 86400UL; }
50  static ulong GetSecondsFromHours( int hours ) { return hours * 3600UL; }
51  static ulong GetSecondsFromMinutes( int minutes ) { return minutes * 60; }
52 private:
53  short _millisec;//[0~999]
54  short _second; // [0~59]
55  short _minute; // [0~59]
56  short _hour; // [0~23]
57  short _day; // [1~31]
58  short _month; // [1~12]
59  short _year; // [1970~2038]
60  short _wday; // 星期几[0~6,0=Sun]
61  short _yday; // 年第几日[1~366,1=January 1]
62 };
63 
64 WINUX_FUNC_DECL(std::ostream &) operator << ( std::ostream & o, DateTimeL const & dt );
65 
72 
73 
74 
75 } // namespace winux
76 
77 #endif // __TIME_HPP__
static ulong GetSecondsFromDays(int days)
Definition: time.hpp:49
本地日期时间。L意思&#39;local&#39;,不包含时区信息
Definition: time.hpp:7
void setHour(short hour)
Definition: time.hpp:34
#define WINUX_DLL
Definition: utilities.hpp:57
void setMonth(short month)
Definition: time.hpp:32
uint64 GetUtcTimeUs()
获取UTC时间微秒数,UTC秒数可以直接除以1000000,或者调用CRT的time(NULL)
short getDayOfYear() const
Definition: time.hpp:29
ulong GetUtcTime()
获取UTC时间秒数,或者调用CRT的time(NULL)
void setDay(short day)
Definition: time.hpp:33
static ulong GetSecondsFromMinutes(int minutes)
Definition: time.hpp:51
uint64 GetUtcTimeMs()
获取UTC时间毫秒数,UTC秒数可以直接除以1000,或者调用CRT的time(NULL)
std::ostream & operator<<(std::ostream &o, ConsoleAttrT< _VarType > const &tr)
Definition: console.hpp:134
short getHour() const
Definition: time.hpp:22
void setSecond(short second)
Definition: time.hpp:36
static ulong GetSecondsFromHours(int hours)
Definition: time.hpp:50
#define WINUX_FUNC_DECL(ret)
Definition: utilities.hpp:61
short getSecond() const
Definition: time.hpp:24
static ulong GetSecondsFromWeeks(int weeks)
Definition: time.hpp:48
short getMonth() const
Definition: time.hpp:20
short getYear() const
Definition: time.hpp:19
short getMillisec() const
Definition: time.hpp:25
short getDayOfWeek() const
Definition: time.hpp:27
void setMillisec(short millisec)
Definition: time.hpp:37
unsigned long long uint64
Definition: utilities.hpp:146
unsigned long ulong
Definition: utilities.hpp:129
void setMinute(short minute)
Definition: time.hpp:35
short getMinute() const
Definition: time.hpp:23
std::basic_string< tchar > String
Definition: utilities.hpp:162
short getDay() const
Definition: time.hpp:21
跨平台基础功能库
Definition: archives.hpp:7
void setYear(short year)
Definition: time.hpp:31