39 #ifndef COMMONCPP_NUMBERS_H_
40 #define COMMONCPP_NUMBERS_H_
42 #ifndef COMMONCPP_CONFIG_H_
43 #include <commoncpp/config.h>
46 #ifndef COMMONCPP_STRING_H_
58 inline void toJulian(
long year,
long month,
long day)
61 inline void fromJulian(
char *buf)
const
65 inline Date(time_t value) :
ucommon::Date(value) {}
67 inline Date(
struct tm *
object) :
ucommon::Date(object) {}
69 inline Date(
const char *ptr,
size_t size = 0) :
ucommon::Date(ptr, size) {}
71 inline Date(
int y,
unsigned m,
unsigned d) :
ucommon::Date(y, m, d) {}
73 inline Date(
const Date&
object) :
ucommon::Date(object) {}
75 inline Date() :
ucommon::Date() {}
77 inline int getYear(
void)
const
80 inline unsigned getMonth(
void)
const
83 inline unsigned getDay(
void)
const
86 inline unsigned getDayOfWeek(
void)
const
89 inline long getJulian(
void)
const
92 inline const char *
get(
char *buffer)
const
95 inline time_t getTime(
void)
const
98 inline bool isValid(
void)
const
105 inline void toSeconds(
int h,
int m = 0,
int s = 0)
108 inline void fromSeconds(
char *buf)
const
112 inline Time(time_t value) :
ucommon::Time(value) {}
114 inline Time(
tm_t *
object) :
ucommon::Time(object) {}
116 inline Time(
const char *ptr,
size_t size) :
ucommon::Time(ptr, size) {}
118 inline Time(
int h,
int m,
int s) :
ucommon::Time(h, m, s) {}
120 inline Time() :
ucommon::Time() {}
122 inline int getHour(
void)
const
125 inline int getMinute(
void)
const
128 inline int getSecond(
void)
const
131 inline const char *
get(
char *buffer)
const
132 {
return put(buffer);}
134 inline bool isValid(
void)
const
142 inline DateTime(time_t time) :
ucommon::DateTime(time) {}
144 inline DateTime(
struct tm *dt) :
ucommon::DateTime(dt) {}
147 inline DateTime(
int year,
unsigned month,
unsigned day,
148 int hour = 0,
int minute = 0,
int second = 0) :
149 ucommon::DateTime(year, month, day, hour, minute, second) {}
151 inline DateTime(
const char *ptr,
size_t size) :
152 ucommon::DateTime(ptr, size) {}
154 inline DateTime(
const DateTime& obj) :
ucommon::DateTime(obj) {}
156 inline DateTime() :
ucommon::DateTime() {}
158 inline int getYear(
void)
const
161 inline unsigned getMonth(
void)
const
164 inline unsigned getDay(
void)
const
167 inline unsigned getDayOfWeek(
void)
const
170 inline long getJulian(
void)
const
173 inline const char *
get(
char *buffer)
const
176 inline time_t getTime(
void)
const
179 inline bool isValid(
void)
const
182 inline int getHour(
void)
const
185 inline int getMinute(
void)
const
188 inline int getSecond(
void)
const
191 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.
The Time class uses a integer representation of the current time.
void set(void)
Set (update) the date with current date.
struct tm tm_t
Convenience type for struct tm.
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 namespace for all ucommon objects.
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.