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_
55 inline void toJulian(
long year,
long month,
long day)
58 inline void fromJulian(
char *buf)
const
62 inline Date(time_t value) : ucommon::Date(value) {};
64 inline Date(
struct tm *
object) : ucommon::Date(object) {};
66 inline Date(
const char *ptr,
size_t size = 0) : ucommon::Date(ptr, size) {};
68 inline Date(
int y,
unsigned m,
unsigned d) : ucommon::Date(y, m, d) {};
70 inline Date(
const Date&
object) : ucommon::Date(object) {};
72 inline Date() : ucommon::Date() {};
74 inline int getYear(
void)
const
77 inline unsigned getMonth(
void)
const
80 inline unsigned getDay(
void)
const
83 inline unsigned getDayOfWeek(
void)
const
86 inline long getJulian(
void)
const
89 inline const char *
get(
char *buffer)
const
92 inline time_t getTime(
void)
const
95 inline bool isValid(
void)
const
102 inline void toSeconds(
int h,
int m = 0,
int s = 0)
105 inline void fromSeconds(
char *buf)
const
109 inline Time(time_t value) : ucommon::Time(value) {};
111 inline Time(
tm_t *
object) : ucommon::Time(object) {};
113 inline Time(
const char *ptr,
size_t size) : ucommon::Time(ptr, size) {};
115 inline Time(
int h,
int m,
int s) : ucommon::Time(h, m, s) {};
117 inline Time() : ucommon::Time() {};
119 inline int getHour(
void)
const
122 inline int getMinute(
void)
const
125 inline int getSecond(
void)
const
128 inline const char *
get(
char *buffer)
const
129 {
return put(buffer);}
131 inline bool isValid(
void)
const
139 inline DateTime(time_t time) : ucommon::DateTime(time) {};
141 inline DateTime(
struct tm *dt) : ucommon::DateTime(dt) {};
144 inline DateTime(
int year,
unsigned month,
unsigned day,
145 int hour = 0,
int minute = 0,
int second = 0) :
146 ucommon::DateTime(year, month, day, hour, minute, second) {};
148 inline DateTime(
const char *ptr,
size_t size) :
149 ucommon::DateTime(ptr, size) {};
151 inline DateTime(
const DateTime& obj) : ucommon::DateTime(obj) {};
153 inline DateTime() : ucommon::DateTime() {};
155 inline int getYear(
void)
const
158 inline unsigned getMonth(
void)
const
161 inline unsigned getDay(
void)
const
164 inline unsigned getDayOfWeek(
void)
const
167 inline long getJulian(
void)
const
170 inline const char *
get(
char *buffer)
const
173 inline time_t getTime(
void)
const
176 inline bool isValid(
void)
const
179 inline int getHour(
void)
const
182 inline int getMinute(
void)
const
185 inline int getSecond(
void)
const
188 inline static tm_t *glt(time_t *time = NULL)
int hour(void) const
Get hours from midnight.
time_t timeref(void) const
Get a time_t for the julian date if in time_t epoch.
int second(void) const
Get seconds from current minute.
A number class that manipulates a string buffer that is also a date.
The Time class uses a integer representation of the current time.
const char * put(char *buffer) const
Get a ISO string representation of the date (yyyy-mm-dd).
Time()
Create a time from current time.
static tm_t * local(time_t *time=((void *) 0))
Fetch an instance of time converted to local time.
void set(void)
Set (update) the date with current date.
int minute(void) const
Get minutes from current hour.
bool is_valid(void) const
Check if time object had valid value.
unsigned month(void) const
Get the month of the date (1-12).
Common C++ generic string class.
The Date class uses a julian date representation of the current year, month, and day.
unsigned day(void) const
Get the day of the month of the date.
struct tm tm_t
Convenience type for struct tm.
bool is_valid(void) const
Test if object is valid.
DateTime()
Construct a new date and time object with current date and time.
unsigned dow(void) const
Get the day of the week (0-7).
const char * put(char *buffer) const
Get a ISO formatted date and time string for current object.
void set(void)
Set (update) the time with current time.
const char * put(char *buffer) const
Get a hh:mm:ss formatted string for current time.
Date()
Construct a new julian date with today's date.
int year(void) const
Get the year of the date.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
bool is_valid(void) const
Check if date is valid.