1 #ifndef COMMONCPP_NUMBERS_H_
2 #define COMMONCPP_NUMBERS_H_
4 #ifndef COMMONCPP_CONFIG_H_
5 #include <commoncpp/config.h>
8 #ifndef COMMONCPP_STRING_H_
18 inline void toJulian(
long year,
long month,
long day)
21 inline void fromJulian(
char *buf)
const
25 inline Date(time_t value) : ucommon::Date(value) {};
27 inline Date(
struct tm *
object) : ucommon::Date(object) {};
29 inline Date(
const char *ptr,
size_t size = 0) : ucommon::Date(ptr, size) {};
31 inline Date(
int y,
unsigned m,
unsigned d) : ucommon::Date(y, m, d) {};
33 inline Date(
const Date&
object) : ucommon::Date(object) {};
35 inline Date() : ucommon::Date() {};
37 inline int getYear(
void)
const
40 inline unsigned getMonth(
void)
const
43 inline unsigned getDay(
void)
const
46 inline unsigned getDayOfWeek(
void)
const
49 inline long getJulian(
void)
const
52 inline const char *
get(
char *buffer)
const
55 inline time_t getTime(
void)
const
58 inline bool isValid(
void)
const
65 inline void toSeconds(
int h,
int m = 0,
int s = 0)
68 inline void fromSeconds(
char *buf)
const
72 inline Time(time_t value) : ucommon::Time(value) {};
74 inline Time(
tm_t *
object) : ucommon::Time(object) {};
76 inline Time(
const char *ptr,
size_t size) : ucommon::Time(ptr, size) {};
78 inline Time(
int h,
int m,
int s) : ucommon::Time(h, m, s) {};
80 inline Time() : ucommon::Time() {};
82 inline int getHour(
void)
const
85 inline int getMinute(
void)
const
88 inline int getSecond(
void)
const
91 inline const char *
get(
char *buffer)
const
94 inline bool isValid(
void)
const
102 inline DateTime(time_t time) : ucommon::DateTime(time) {};
104 inline DateTime(
struct tm *dt) : ucommon::DateTime(dt) {};
107 inline DateTime(
int year,
unsigned month,
unsigned day,
108 int hour = 0,
int minute = 0,
int second = 0) :
109 ucommon::DateTime(year, month, day, hour, minute, second) {};
111 inline DateTime(
const char *ptr,
size_t size) :
112 ucommon::DateTime(ptr, size) {};
114 inline DateTime(
const DateTime& obj) : ucommon::DateTime(obj) {};
116 inline DateTime() : ucommon::DateTime() {};
118 inline int getYear(
void)
const
121 inline unsigned getMonth(
void)
const
124 inline unsigned getDay(
void)
const
127 inline unsigned getDayOfWeek(
void)
const
130 inline long getJulian(
void)
const
133 inline const char *
get(
char *buffer)
const
136 inline time_t getTime(
void)
const
139 inline bool isValid(
void)
const
142 inline int getHour(
void)
const
145 inline int getMinute(
void)
const
148 inline int getSecond(
void)
const
151 inline static tm_t *glt(time_t *time = NULL)
bool is_valid(void) const
Check if date is valid.
Common C++ generic string class.
int hour(void) const
Get hours from midnight.
The Datetime class uses a julian date representation of the current year, month, and day and a intege...
Time()
Create a time from current time.
const char * put(char *buffer) const
Get a ISO string representation of the date (yyyy-mm-dd).
static tm_t * local(time_t *time=((void *) 0))
Fetch an instance of time converted to local time.
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.
bool is_valid(void) const
Check if time object had valid value.
bool is_valid(void) const
Test if object is valid.
void set(void)
Set (update) the date with current date.
int minute(void) const
Get minutes from current hour.
unsigned day(void) const
Get the day of the month of the date.
A number class that manipulates a string buffer that is also a date.
The Time class uses a integer representation of the current time.
int year(void) const
Get the year of the date.
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).
unsigned month(void) const
Get the month of the date (1-12).
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.
struct tm tm_t
Convenience type for struct tm.
Date()
Construct a new julian date with today's date.
The Date class uses a julian date representation of the current year, month, and day.
const char * put(char *buffer) const
Get a ISO formatted date and time string for current object.