120 return !(*
this == other);
136 return (*
this == other) || (*
this < other);
152 return (*
this == other) || (*
this > other);
163 if (day_difference != 0) {
164 day += day_difference;
180 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
191void DateTime::getDateParts (
int* year,
short* month,
short* day,
short* hour,
short* minute,
short* second)
const
209int DateTime::getYear (
void)
const
218 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
226int DateTime::getMonth (
void)
const
235 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
243int DateTime::getDay (
void)
const
252 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
260int DateTime::getHour (
void)
const
269 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
277int DateTime::getMinute (
void)
const
286 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
294int DateTime::getSecond (
void)
const
303 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
322const char* DateTime::asString (
const char*
format =
"%Y-%m-%d %H:%M:%S")
const
331 getDateParts(&year, &month, &
day, &hour, &minute, &
second);
334 int formatLength = strlen(
format);
336 for (
int i = 0;
i < formatLength;
i++) {
346 if (
i >= formatLength) {
356 dateLength += log10(year) + 1;
377 if (dateLength == -1)
381 static char string[64] =
"";
383 for (
int i = 0;
i < formatLength;
i++) {
385 string[stringIdx++] =
format[
i];
392 string[stringIdx++] =
'%';
395 Com_sprintf(
string + stringIdx, dateLength - stringIdx,
"%d", year);
396 stringIdx += log10(year) + 1;
399 Com_sprintf(
string + stringIdx, dateLength - stringIdx,
"%02d", month);
403 Com_sprintf(
string + stringIdx, dateLength - stringIdx,
"%02d",
day);
407 Com_sprintf(
string + stringIdx, dateLength - stringIdx,
"%02d", hour);
411 Com_sprintf(
string + stringIdx, dateLength - stringIdx,
"%02d", minute);
423 string[stringIdx++] =
'\0';
DateTime class definition.
bool operator<(const DateTime &other) const
Decides if the left DateTime is earlier than the right one.
DateTime & operator+=(const DateTime &other)
Adds a DateTime (duration) to the left DateTime object.
bool operator>=(const DateTime &other) const
Decides if the left DateTime is later or equal to the right one.
DateTime(int day=0, int second=0)
Construct for DateTime class from date as days and time as seconds.
static const int SECONDS_PER_DAY
int getTimeAsSeconds() const
Return the time part of the DateTime as seconds.
bool operator==(const DateTime &other) const
Decides whether two DateTimes are equal.
void reCalculate(void)
Handle over- and underflowing date/time parts.
static const short SECONDS_PER_MINUTE
bool operator!=(const DateTime &other) const
Decides whether two DateTimes are different.
DateTime operator+(const DateTime &other) const
Calcluate the summary of two DateTime objects in a new one.
static const short MONTHS_PER_YEAR
static const short SECONDS_PER_HOUR
bool operator>(const DateTime &other) const
Decides if the left DateTime is later than the right one.
bool operator<=(const DateTime &other) const
Decides if the left DateTime is earlier or equal to the right one.
static const int DAYS_PER_YEAR
DateTime operator-(const DateTime &other) const
Calcluate the difference of two DateTime objects in a new one.
DateTime & operator-=(const DateTime &other)
Substracts a DateTime (duration) from the left DateTime object.
int getDateAsDays() const
Return the date part of the DateTime as days.
const int DAYS_PER_MONTH[DateTime::MONTHS_PER_YEAR]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void format(__printf__, 1, 2)))
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking