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
220 String operator()()
const;
239 Date& operator+=(
long offset);
246 Date& operator-=(
long offset);
253 Date operator+(
long days);
260 Date operator-(
long days);
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;
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();};
480 {
return !is_valid();};
487 long operator-(
const Time &reference);
494 Time operator+(
long seconds);
501 Time operator-(
long seconds);
507 inline operator long()
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);
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);
long operator-(const Date &date)
Operator to compute number of days between two dates.
const char * c_str(void)
Extract char from string.
long operator*() const
Access julian value.
Date & operator-=(long offset)
Decrement date by offset.
bool operator<=(const Date &date) const
Compare julian date if earlier than or equal to another date.
bool is_valid(void) const
Check if date is valid.
Used for processing input.
static const long c_day
Constant for number of seconds in a day.
void set(void)
Set (update) the date and time with current date and time.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
Various miscellaneous platform specific headers and defines.
long get(void) const
Get the date as a number for the object or 0 if invalid.
static const size_t sz_string
Size of datetime string field.
Time tod_t
Convenience type for using Time object.
DateTimeString datetimestring_t
Convenience type for using DateTimeString object.
const char * put(char *buffer) const
Get a ISO string representation of the date (yyyy-mm-dd).
Date date_t
Convenience type for using Date object.
Support classes for manipulation of numbers as strings.
static const long c_hour
Constant for number of seconds in a hour.
virtual int _input(int code)=0
Extract formatted string for object.
A common string class and character string support functions.
virtual const char * _print(void) const =0
Extract formatted string for object.
void set(void)
Set (update) the date with current date.
Date & operator++()
Increment date by one day.
virtual void update(void)
A method to use to "post" any changed values when shadowing a mixed object class. ...
Date operator-(long days)
Subtract days from a julian date in an expression.
bool operator!=(const Date &date) const
Compare julian dates if not same date.
bool operator<(const Date &date) const
Compare julian date if earlier than another date.
A number class that manipulates a string buffer that is also a date.
The Time class uses a integer representation of the current time.
Date operator+(long days)
Add days to julian date in an expression.
bool operator!() const
Check if time object has valid value for ! operator.
Used for forming stream output.
DateTime datetime_t
Convenience type for using DateTime object.
static const size_t sz_string
Size of date string field.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
void update(void)
A method to use to "post" any changed values when shadowing a mixed object class. ...
static const long c_week
Constant for number of seconds in a week.
static const size_t sz_string
Size of time string field.
A number manipulation class.
Date & operator--()
Decrement date by one day.
long operator*() const
Get object time in seconds.
A copy-on-write string class that operates by reference count.
struct tm tm_t
Convenience type for struct tm.
bool operator!() const
Check if julian date is not valid.
bool operator>(const Date &date) const
Compare julian date if later than another date.
The Date class uses a julian date representation of the current year, month, and day.
bool operator>=(const Date &date) const
Compare julian date if later than or equal to another date.
Date & operator+=(long offset)
Increment date by offset.
Date & operator=(const Date &date)
Assign date from another date object.
Generic smart pointer class.
bool operator==(const Date &date) const
Compare julian dates if same date.