29 #ifndef _UCOMMON_DATETIME_H_
30 #define _UCOMMON_DATETIME_H_
32 #ifndef _UCOMMON_CONFIG_H_
36 #ifndef _UCOMMON_NUMBERS_H_
40 #ifndef _UCOMMON_STRING_H_
51 #define DATE_STRING_SIZE 10
52 #define DATE_BUFFER_SIZE 11
53 #define TIME_STRING_SIZE 8
54 #define TIME_BUFFER_SIZE 9
55 #define DATETIME_STRING_SIZE 19
56 #define DATETIME_BUFFER_SIZE 20
83 void set(
long year,
long month,
long day);
89 virtual void update(
void);
107 Date(
struct tm *
object);
122 Date(
int year,
unsigned month,
unsigned day);
144 int year(
void)
const;
150 unsigned month(
void)
const;
156 unsigned day(
void)
const;
162 unsigned dow(
void)
const;
169 const char *put(
char *buffer)
const;
175 time_t timeref(
void)
const;
181 long get(void)
const;
193 void set(
const char *
pointer,
size_t size = 0);
199 bool is_valid(
void)
const;
205 inline operator long()
const
212 inline long operator*()
const
220 String operator()()
const;
239 Date& operator+=(
long offset);
246 Date& operator-=(
long offset);
253 Date operator+(
long days);
260 Date operator-(
long days);
267 inline long operator-(
const Date &date)
268 {
return (julian - date.julian);};
282 bool operator==(
const Date& date)
const;
289 bool operator!=(
const Date& date)
const;
296 bool operator<(
const Date& date)
const;
303 bool operator<=(
const Date& date)
const;
310 bool operator>(
const Date& date)
const;
317 bool operator>=(
const Date& date)
const;
323 inline bool operator!()
const
324 {
return !is_valid();};
330 inline operator bool()
const
331 {
return is_valid();};
351 virtual void update(
void);
354 void set(
int hour,
int minute = 0,
int second = 0);
401 Time(
int hour,
int minute,
int second);
423 long get(void)
const;
429 int hour(
void)
const;
435 int minute(
void)
const;
441 int second(
void)
const;
448 const char *put(
char *buffer)
const;
460 void set(
const char *
pointer,
size_t size = 0);
466 bool is_valid(
void)
const;
472 inline operator bool()
const
473 {
return is_valid();};
479 inline bool operator!()
const
480 {
return !is_valid();};
487 long operator-(
const Time &reference);
494 Time operator+(
long seconds);
501 Time operator-(
long seconds);
507 inline operator long()
514 inline long operator*()
const
521 String operator()()
const;
547 Time& operator+=(
long seconds);
554 Time& operator-=(
long seconds);
561 bool operator==(
const Time &time)
const;
568 bool operator!=(
const Time &time)
const;
575 bool operator<(
const Time &time)
const;
582 bool operator<=(
const Time &time)
const;
589 bool operator>(
const Time &time)
const;
596 bool operator>=(
const Time &time)
const;
647 DateTime(
int year,
unsigned month,
unsigned day,
648 int hour = 0,
int minute = 0,
int second = 0);
671 const char *
put(
char *buffer)
const;
677 time_t
get(void)
const;
797 operator bool()
const;
803 inline operator long()
const
815 operator double()
const;
822 String format(
const char *strftime)
const;
832 static tm_t *local(time_t *time = NULL);
842 static tm_t *gmt(time_t *time = NULL);
866 DATE, TIME, BOTH} mode_t;
869 char buffer[DATETIME_BUFFER_SIZE];
905 int hour = 0,
int minute = 0,
int second = 0);
928 inline const char *c_str(
void)
936 inline operator const char *(void)
948 void set(mode_t string);
986 enum {DATE, TIME, DATETIME} mode;
991 const char *
_print(
void)
const;
996 isotime(Date& date, Time& time);
1022 __EXPORT
long tzoffset(
struct timezone *tz = NULL);