#include <DateTime.h>
|
| | DateTime () |
| | DateTime (const DateTime &_src) |
| | DateTime (time_t _timer) |
| | DateTime (const Date &_date, const Time &_time) |
| | DateTime (int _year, int _month, int _day, int _hour, int _min, int _sec, int _millisecond=0) |
| void | assign (time_t _timer) |
| void | assign (const Date &_date, const Time &_time) |
| void | assign (int _year, int _month, int _day, int _hour, int _min, int _sec, int _millisecond=0) |
| const DateTime & | operator= (const DateTime &_src) |
| const DateTime & | operator+= (const Interval &_iv) |
| const DateTime & | operator-= (const Interval &_iv) |
| String | toString () const |
| String | toStringF (const wchar_t *_format=NULL) const |
| Date & | date () |
| const Date & | date () const |
| Time & | time () |
| const Time & | time () const |
Definition at line 213 of file DateTime.h.
◆ DateTime() [1/5]
◆ DateTime() [2/5]
| DateTime::DateTime |
( |
const DateTime & | _src | ) |
|
◆ DateTime() [3/5]
| DateTime::DateTime |
( |
time_t | _timer | ) |
|
Definition at line 705 of file DateTime.cpp.
706{
708}
void assign(time_t _timer)
◆ DateTime() [4/5]
| DateTime::DateTime |
( |
const Date & | _date, |
|
|
const Time & | _time ) |
◆ DateTime() [5/5]
| DateTime::DateTime |
( |
int | _year, |
|
|
int | _month, |
|
|
int | _day, |
|
|
int | _hour, |
|
|
int | _min, |
|
|
int | _sec, |
|
|
int | _millisecond = 0 ) |
Definition at line 716 of file DateTime.cpp.
718{
719 __date.assign(_year, _month, _day);
720 __time.assign(_hour, _min, _sec, _millisecond);
721}
◆ assign() [1/3]
| void DateTime::assign |
( |
const Date & | _date, |
|
|
const Time & | _time ) |
◆ assign() [2/3]
| void DateTime::assign |
( |
int | _year, |
|
|
int | _month, |
|
|
int | _day, |
|
|
int | _hour, |
|
|
int | _min, |
|
|
int | _sec, |
|
|
int | _millisecond = 0 ) |
Definition at line 754 of file DateTime.cpp.
756{
757 __date.assign(_year, _month, _day);
758 __time.assign(_hour, _min, _sec, _millisecond);
759}
◆ assign() [3/3]
| void DateTime::assign |
( |
time_t | _timer | ) |
|
Definition at line 723 of file DateTime.cpp.
724{
725 long tm_gmtoff = 0;
726
727#if __DCL_WINDOWS
728 long seconds;
729 _get_timezone(&seconds);
730 tm_gmtoff = -seconds;
731#else
732 struct tm tm;
733 localtime_r(&_timer, &tm);
734 tm_gmtoff = tm.tm_gmtoff;
735#endif
736
738 (
long) (719163 + ((_timer + tm_gmtoff) /
SEC_PER_DAY))
739 );
741 0,
742 0,
744 0
745 );
746}
◆ compare()
Definition at line 869 of file DateTime.cpp.
870{
872 return -1;
875 return -1;
877 return 0;
878 }
879 return 1;
880}
◆ date() [1/2]
| Date & DateTime::date |
( |
| ) |
|
|
inline |
◆ date() [2/2]
| const Date & DateTime::date |
( |
| ) |
const |
|
inline |
◆ getCurrentLocalTime()
| DateTime DateTime::getCurrentLocalTime |
( |
| ) |
|
|
static |
Definition at line 937 of file DateTime.cpp.
938{
940#if __DCL_WINDOWS
941 struct _timeb timeb;
942 _ftime_s(&timeb);
943
945 (
long) (719163 + ((timeb.time - timeb.timezone * 60) /
SEC_PER_DAY))
946 );
948 0,
949 -timeb.timezone,
951 timeb.millitm
952 );
953#else
954 time_t timer;
955 struct tm tm;
957 localtime_r(&timer, &tm);
958
959 struct timeval tv;
960 gettimeofday(&tv,
NULL);
961
964 );
966 0,
967 0,
969 tv.tv_usec / 1000
970 );
971#endif
973}
◆ getCurrentTimeMillis()
| int64_t DateTime::getCurrentTimeMillis |
( |
| ) |
|
|
static |
Definition at line 882 of file DateTime.cpp.
883{
884#if __DCL_WINDOWS
886 GetSystemTime(&
time);
887
889 int64_t
r = dt.days() * 24;
890 r = (
r +
time.wHour) * 60;
891 r = (
r +
time.wMinute) * 60;
892 r = (
r +
time.wSecond) * 1000;
893 r +=
time.wMilliseconds;
895#else
896 struct timeval tv;
897 gettimeofday(&tv,
NULL);
898 int64_t
r = tv.tv_sec * 1000;
899 r += tv.tv_usec / 1000;
901#endif
902}
◆ getCurrentUTCTime()
| DateTime DateTime::getCurrentUTCTime |
( |
| ) |
|
|
static |
Definition at line 904 of file DateTime.cpp.
905{
907#if __DCL_WINDOWS
908 struct _timeb timeb;
909 _ftime_s(&timeb);
910
913 );
915 0,
916 0,
918 timeb.millitm
919 );
920#else
921 struct timeval tv;
922 gettimeofday(&tv,
NULL);
923
926 );
928 0,
929 0,
931 tv.tv_usec / 1000
932 );
933#endif
935}
◆ operator+=()
Definition at line 769 of file DateTime.cpp.
770{
772 + (int64_t)
__time.totalMilliSeconds()
774
777
778 return *this;
779}
int64_t totalMilliSeconds() const
◆ operator-=()
Definition at line 781 of file DateTime.cpp.
782{
784 + (int64_t)
__time.totalMilliSeconds()
786
789
790 return *this;
791}
◆ operator=()
Definition at line 761 of file DateTime.cpp.
762{
765
766 return *this;
767}
◆ time() [1/2]
| Time & DateTime::time |
( |
| ) |
|
|
inline |
◆ time() [2/2]
| const Time & DateTime::time |
( |
| ) |
const |
|
inline |
◆ toString()
| String DateTime::toString |
( |
| ) |
const |
◆ toStringF()
| String DateTime::toStringF |
( |
const wchar_t * | _format = NULL | ) |
const |
Definition at line 834 of file DateTime.cpp.
835{
836 if (!_format)
838
840
841 int year, month, day, hour, min, sec, msec;
842 __date.decode(year, month, day);
843 __time.decode(hour, min, sec, msec);
844
846 time.tm_year = year - 1900;
847 time.tm_mon = month - 1;
852
856
860 buf->__dataLength =
n;
862
866}
#define DATETIME_FORMAT_BUFFER_SIZE
#define __DCL_ASSERT(expr)
void CharsetConvertException *size_t n
static const wchar_t * FORMAT_STRING
◆ __date
◆ __time
◆ FORMAT_STRING
| const wchar_t * DateTime::FORMAT_STRING = L"%Y-%m-%d %H:%M:%S" |
|
static |
The documentation for this class was generated from the following files: