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(
const 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
351 virtual void update(
void);
354 void set(
int hour,
int minute = 0,
int second = 0);
380 Time(
const time_t value);
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
480 {
return !is_valid();}
487 long operator-(
const Time &reference);
494 Time operator+(
long seconds);
501 Time operator-(
long seconds);
507 inline operator long()
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;
683 bool is_valid(
void)
const;
690 long operator-(
const DateTime &datetime);
748 bool operator==(
const DateTime& datetime)
const;
755 bool operator!=(
const DateTime& datetime)
const;
762 bool operator<(
const DateTime& datetime)
const;
770 bool operator<=(
const DateTime& datetime)
const;
777 bool operator>(
const DateTime& datetime)
const;
785 bool operator>=(
const DateTime& datetime)
const;
791 bool operator!()
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(
const time_t *time = NULL);
842 static tm_t *gmt(
const 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)
const
936 inline operator const char *(void)
const
948 void set(mode_t
string);
986 enum {DATE, TIME, DATETIME} mode;
991 const char *_print(
void)
const;
993 int _input(
int code);
996 isotime(Date& date, Time& time);
1024 __EXPORT
long tzoffset(
struct timezone *tz = NULL);
long get(void) const
Get the date as a number for the object or 0 if invalid.
bool operator!() const
Check if julian date is not valid.
long operator*() const
Access julian value.
bool operator!() const
Check if time object has valid value for ! operator.
long operator-(const Date &date)
Operator to compute number of days between two dates.
Generic smart pointer class.
static const size_t sz_string
Size of time string field.
A copy-on-write string class that operates by reference count.
struct tm tm_t
Convenience type for struct tm.
Common namespace for all ucommon objects.
DateTime datetime_t
Convenience type for using DateTime object.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
Support classes for manipulation of numbers as strings.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
Various miscellaneous platform specific headers and defines.
long operator*() const
Get object time in seconds.
A number manipulation class.
static const size_t sz_string
Size of date string field.
static const long c_day
Constant for number of seconds in a day.
A number class that manipulates a string buffer that is also a date.
Used for processing input.
const char * c_str(void) const
Extract char from string.
static const size_t sz_string
Size of datetime string field.
static const long c_week
Constant for number of seconds in a week.
static const long c_hour
Constant for number of seconds in a hour.
The Time class uses a integer representation of the current time.
DateTimeString datetimestring_t
Convenience type for using DateTimeString object.
Used for forming stream output.
The Date class uses a julian date representation of the current year, month, and day.
A common string class and character string support functions.
Time tod_t
Convenience type for using Time object.
Date date_t
Convenience type for using Date object.