38 #ifndef COMMONCPP_NUMBERS_H_
39 #define COMMONCPP_NUMBERS_H_
41 #ifndef COMMONCPP_CONFIG_H_
42 #include <commoncpp/config.h>
45 #ifndef COMMONCPP_STRING_H_
57 inline void toJulian(
long year,
long month,
long day)
60 inline void fromJulian(
char *buf)
const
64 inline Date(time_t value) :
ucommon::Date(value) {}
66 inline Date(
struct tm *
object) :
ucommon::Date(object) {}
68 inline Date(
const char *ptr,
size_t size = 0) :
ucommon::Date(ptr, size) {}
70 inline Date(
int y,
unsigned m,
unsigned d) :
ucommon::Date(y, m, d) {}
72 inline Date(
const Date&
object) :
ucommon::Date(object) {}
74 inline Date() :
ucommon::Date() {}
76 inline int getYear(
void)
const
79 inline unsigned getMonth(
void)
const
82 inline unsigned getDay(
void)
const
85 inline unsigned getDayOfWeek(
void)
const
88 inline long getJulian(
void)
const
91 inline const char *
get(
char *buffer)
const
94 inline time_t getTime(
void)
const
97 inline bool isValid(
void)
const
104 inline void toSeconds(
int h,
int m = 0,
int s = 0)
107 inline void fromSeconds(
char *buf)
const
111 inline Time(time_t value) :
ucommon::Time(value) {}
113 inline Time(
tm_t *
object) :
ucommon::Time(object) {}
115 inline Time(
const char *ptr,
size_t size) :
ucommon::Time(ptr, size) {}
117 inline Time(
int h,
int m,
int s) :
ucommon::Time(h, m, s) {}
119 inline Time() :
ucommon::Time() {}
121 inline int getHour(
void)
const
124 inline int getMinute(
void)
const
127 inline int getSecond(
void)
const
130 inline const char *
get(
char *buffer)
const
131 {
return put(buffer);}
133 inline bool isValid(
void)
const
141 inline DateTime(time_t time) :
ucommon::DateTime(time) {}
143 inline DateTime(
struct tm *dt) :
ucommon::DateTime(dt) {}
146 inline DateTime(
int year,
unsigned month,
unsigned day,
147 int hour = 0,
int minute = 0,
int second = 0) :
148 ucommon::DateTime(year, month, day, hour, minute, second) {}
150 inline DateTime(
const char *ptr,
size_t size) :
151 ucommon::DateTime(ptr, size) {}
153 inline DateTime(
const DateTime& obj) :
ucommon::DateTime(obj) {}
155 inline DateTime() :
ucommon::DateTime() {}
157 inline int getYear(
void)
const
160 inline unsigned getMonth(
void)
const
163 inline unsigned getDay(
void)
const
166 inline unsigned getDayOfWeek(
void)
const
169 inline long getJulian(
void)
const
172 inline const char *
get(
char *buffer)
const
175 inline time_t getTime(
void)
const
178 inline bool isValid(
void)
const
181 inline int getHour(
void)
const
184 inline int getMinute(
void)
const
187 inline int getSecond(
void)
const
190 inline static tm_t *glt(time_t *time = NULL)
time_t timeref(void) const
Get a time_t for the julian date if in time_t epoch.
A number class that manipulates a string buffer that is also a date.
struct tm tm_t
Convenience type for struct tm.
Common namespace for all ucommon objects.
void set(void)
Set (update) the date with current date.
The Date class uses a julian date representation of the current year, month, and day.
bool is_valid(void) const
Test if object is valid.
Common C++ generic string class.
const char * put(char *buffer) const
Get a ISO formatted date and time string for current object.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
static tm_t * local(const time_t *time=((void *) 0))
Fetch an instance of time converted to local time.
The Time class uses a integer representation of the current time.