Rudiments
datetime.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_DATETIME_H
5 #define RUDIMENTS_DATETIME_H
6 
7 #include <rudiments/private/datetimeincludes.h>
8 
12 class RUDIMENTS_DLLSPEC datetime {
13  public:
14 
17 
20 
29  bool initialize(const char *tmstring);
30 
36  bool initialize(time_t seconds);
37 
43  bool initialize(time_t seconds, time_t microseconds);
44 
56  bool initialize(const void *tmstruct);
57 
58 
64 
75  bool getHardwareDateAndTime(const char *hwtz);
76 
84  bool getAdjustedHardwareDateAndTime(const char *hwtz);
85 
91 
102  bool setHardwareDateAndTime(const char *hwtz);
103 
104 
107  int32_t getHour() const;
108 
111  int32_t getMinutes() const;
112 
115  int32_t getSeconds() const;
116 
119  int32_t getMicroseconds() const;
120 
123  int32_t getMonth() const;
124 
128  const char *getMonthName() const;
129 
133  const char *getMonthAbbreviation() const;
134 
138  int32_t getDayOfMonth() const;
139 
143  int32_t getDayOfWeek() const;
144 
148  int32_t getDayOfYear() const;
149 
153  int32_t getWeekOfYear() const;
154 
158  int32_t getYear() const;
159 
163  int32_t getShortYear() const;
164 
167  int32_t getCentury() const;
168 
171  bool isDaylightSavingsTime() const;
172 
174  const char *getTimeZoneString() const;
175 
177  int32_t getTimeZoneOffset() const;
178 
189  bool adjustTimeZone(const char *newtz);
190 
201  bool adjustTimeZone(const char *newtz, bool ignoredst);
202 
203 
206  bool setSeconds(int32_t seconds);
207 
211  bool setMicroseconds(int32_t microseconds);
212 
215  bool setMinutes(int32_t minutes);
216 
219  bool setHours(int32_t hours);
220 
223  bool setDays(int32_t days);
224 
227  bool setMonths(int32_t months);
228 
231  bool setYears(int32_t years);
232 
235  bool addSeconds(int32_t seconds);
236 
239  bool addMicroseconds(int32_t microseconds);
240 
243  bool addMinutes(int32_t minutes);
244 
247  bool addHours(int32_t hours);
248 
251  bool addDays(int32_t days);
252 
255  bool addMonths(int32_t months);
256 
259  bool addYears(int32_t years);
260 
261 
268  const char *getString();
269 
282  const char *getString(bool microseconds);
283 
284 
291  const char *getSqlString();
292 
305  const char *getSqlString(bool microseconds);
306 
307 
309  time_t getEpoch() const;
310 
311 
314  static const char * const *getTimeZoneAbbreviations();
315 
320  static const int32_t *getTimeZoneOffsets();
321 
328  static bool validDateTime(const char *string);
329 
336  static char *getString(time_t seconds);
337 
344  static char *getString(time_t seconds, time_t microseconds);
345 
352  static char *getString(const void *tmstruct);
353 
360  static time_t getEpoch(const char *datestring);
361 
368  static time_t getEpoch(const void *tmstruct);
369 
371  static bool parse(const char *datetime,
372  bool ddmm, bool yyyyddmm,
373  const char *datedelimiters,
374  int16_t *year, int16_t *month,
375  int16_t *day, int16_t *hour,
376  int16_t *minute, int16_t *second,
377  int32_t *microsecond, bool *isnegative);
378 
380  static char *formatAs(const char *format,
381  int16_t year, int16_t month,
382  int16_t day, int16_t hour,
383  int16_t minute, int16_t second,
384  int32_t microsecond, bool isnegative);
385 
396  static void setTimeMutex(threadmutex *mtx);
397 
398  #include <rudiments/private/datetime.h>
399 };
400 
401 #endif
Definition: datetime.h:12
const char * getString(bool microseconds)
const char * getTimeZoneString() const
static const int32_t * getTimeZoneOffsets()
time_t getEpoch() const
bool setMinutes(int32_t minutes)
bool isDaylightSavingsTime() const
bool addDays(int32_t days)
bool setSeconds(int32_t seconds)
static bool validDateTime(const char *string)
static char * formatAs(const char *format, int16_t year, int16_t month, int16_t day, int16_t hour, int16_t minute, int16_t second, int32_t microsecond, bool isnegative)
bool setHours(int32_t hours)
bool addMonths(int32_t months)
int32_t getCentury() const
bool setHardwareDateAndTime(const char *hwtz)
bool getSystemDateAndTime()
const char * getString()
int32_t getHour() const
bool setYears(int32_t years)
int32_t getMinutes() const
bool adjustTimeZone(const char *newtz)
int32_t getDayOfYear() const
static const char *const * getTimeZoneAbbreviations()
static bool parse(const char *datetime, bool ddmm, bool yyyyddmm, const char *datedelimiters, int16_t *year, int16_t *month, int16_t *day, int16_t *hour, int16_t *minute, int16_t *second, int32_t *microsecond, bool *isnegative)
bool initialize(const char *tmstring)
const char * getMonthName() const
int32_t getShortYear() const
bool initialize(time_t seconds, time_t microseconds)
static char * getString(const void *tmstruct)
static void setTimeMutex(threadmutex *mtx)
bool addMicroseconds(int32_t microseconds)
int32_t getDayOfMonth() const
bool initialize(time_t seconds)
bool adjustTimeZone(const char *newtz, bool ignoredst)
bool setDays(int32_t days)
int32_t getSeconds() const
const char * getMonthAbbreviation() const
int32_t getDayOfWeek() const
bool addMinutes(int32_t minutes)
bool initialize(const void *tmstruct)
bool setMonths(int32_t months)
static time_t getEpoch(const char *datestring)
bool getAdjustedHardwareDateAndTime(const char *hwtz)
const char * getSqlString(bool microseconds)
int32_t getMonth() const
int32_t getYear() const
static char * getString(time_t seconds)
bool setMicroseconds(int32_t microseconds)
int32_t getMicroseconds() const
static char * getString(time_t seconds, time_t microseconds)
bool addSeconds(int32_t seconds)
bool setSystemDateAndTime()
int32_t getTimeZoneOffset() const
static time_t getEpoch(const void *tmstruct)
bool addYears(int32_t years)
const char * getSqlString()
bool addHours(int32_t hours)
int32_t getWeekOfYear() const
bool getHardwareDateAndTime(const char *hwtz)
Definition: threadmutex.h:11