30 #ifndef _UCOMMON_DATETIME_H_ 31 #define _UCOMMON_DATETIME_H_ 33 #ifndef _UCOMMON_CONFIG_H_ 37 #ifndef _UCOMMON_NUMBERS_H_ 41 #ifndef _UCOMMON_TYPEREF_H_ 52 #define DATE_STRING_SIZE 10 53 #define DATE_BUFFER_SIZE 11 54 #define TIME_STRING_SIZE 8 55 #define TIME_BUFFER_SIZE 9 56 #define DATETIME_STRING_SIZE 19 57 #define DATETIME_BUFFER_SIZE 20 84 void set(
long year,
long month,
long day);
90 virtual void update(
void);
108 Date(
const struct tm *
object);
123 Date(
int year,
unsigned month,
unsigned day);
145 int year(
void)
const;
151 unsigned month(
void)
const;
157 unsigned day(
void)
const;
163 unsigned dow(
void)
const;
170 const char *put(
char *buffer)
const;
176 time_t timeref(
void)
const;
182 long get(
void)
const;
194 void set(
const char *
pointer,
size_t size = 0);
200 bool is_valid(
void)
const;
206 inline operator long()
const {
214 inline long operator*()
const {
223 stringref_t operator()()
const;
242 Date& operator+=(
long offset);
249 Date& operator-=(
long offset);
256 const Date operator+(
long days)
const;
263 const Date operator-(
long days)
const;
271 return (julian - date.julian);
286 bool operator==(
const Date& date)
const;
293 bool operator!=(
const Date& date)
const;
300 bool operator<(
const Date& date)
const;
307 bool operator<=(
const Date& date)
const;
314 bool operator>(
const Date& date)
const;
321 bool operator>=(
const Date& date)
const;
335 inline operator bool()
const {
357 virtual void update(
void);
360 void set(
int hour,
int minute = 0,
int second = 0);
386 Time(
const time_t value);
407 Time(
int hour,
int minute,
int second);
429 long get(
void)
const;
435 int hour(
void)
const;
441 int minute(
void)
const;
447 int second(
void)
const;
454 const char *put(
char *buffer)
const;
466 void set(
const char *
pointer,
size_t size = 0);
472 bool is_valid(
void)
const;
478 inline operator bool()
const {
495 long operator-(
const Time &reference);
502 const Time operator+(
long seconds)
const;
509 const Time operator-(
long seconds)
const;
515 inline operator long()
const {
523 inline long operator*()
const {
531 stringref_t operator()()
const;
557 Time& operator+=(
long seconds);
564 Time& operator-=(
long seconds);
571 bool operator==(
const Time &time)
const;
578 bool operator!=(
const Time &time)
const;
585 bool operator<(
const Time &time)
const;
592 bool operator<=(
const Time &time)
const;
599 bool operator>(
const Time &time)
const;
606 bool operator>=(
const Time &time)
const;
621 virtual void update(
void) __OVERRIDE;
657 DateTime(
int year,
unsigned month,
unsigned day,
658 int hour = 0,
int minute = 0,
int second = 0);
681 const char *put(
char *buffer)
const;
687 time_t get(
void)
const;
693 bool is_valid(
void)
const;
700 long operator-(
const DateTime &datetime);
731 const DateTime operator+(
long seconds)
const;
739 const DateTime operator-(
long seconds)
const;
758 bool operator==(
const DateTime& datetime)
const;
765 bool operator!=(
const DateTime& datetime)
const;
772 bool operator<(
const DateTime& datetime)
const;
780 bool operator<=(
const DateTime& datetime)
const;
787 bool operator>(
const DateTime& datetime)
const;
795 bool operator>=(
const DateTime& datetime)
const;
801 bool operator!()
const;
807 operator bool()
const;
813 inline operator long()
const {
826 operator double()
const;
833 stringref_t format(
const char *strftime)
const;
843 static tm_t *local(
const time_t *time = NULL);
853 static tm_t *gmt(
const time_t *time = NULL);
859 static void release(
tm_t *
object);
881 char buffer[DATETIME_BUFFER_SIZE];
885 virtual void update(
void) __OVERRIDE;
917 int hour = 0,
int minute = 0,
int second = 0);
940 inline const char *
c_str(
void)
const {
949 inline operator const char *(void)
const {
962 void set(mode_t
string);
974 virtual void update(
void) __OVERRIDE;
1001 DATE, TIME, DATETIME
1008 const char *_print(
void)
const;
1010 int _input(
int code) __OVERRIDE;
1013 isotime(Date& date, Time& time);
1014 isotime(Date& date);
1015 isotime(Time& time);
The Date class uses a julian date representation of the current year, month, and day.
DateTimeString datetimestring_t
Convenience type for using DateTimeString object.
const char * c_str(void) const
Extract char from string.
Time tod_t
Convenience type for using Time object.
bool operator!() const
Check if julian date is not valid.
Date date_t
Convenience type for using Date object.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
static const size_t sz_string
Size of date string field.
bool operator!() const
Check if time object has valid value for ! operator.
static const size_t sz_string
Size of datetime string field.
A number class that manipulates a string buffer that is also a date.
static const size_t sz_string
Size of time string field.
long get(void) const
Get the date as a number for the object or 0 if invalid.
DateTime datetime_t
Convenience type for using DateTime object.
static const long c_hour
Constant for number of seconds in a hour.
Used for processing input.
Various miscellaneous platform specific headers and defines.
struct tm tm_t
Convenience type for struct tm.
Common namespace for all ucommon objects.
Support classes for manipulation of numbers as strings.
A number manipulation class.
The Time class uses a integer representation of the current time.
Used for forming stream output.
Generic smart pointer class.
long operator-(const Date &date)
Operator to compute number of days between two dates.
static const long c_day
Constant for number of seconds in a day.
A thread-safe atomic heap management system.
static const long c_week
Constant for number of seconds in a week.