21 #ifndef __EDELIB_DATETIME_H__
22 #define __EDELIB_DATETIME_H__
24 #include "edelib-global.h"
36 unsigned long timeval;
38 bool load(
const char* zone);
39 bool load_local(
void);
56 bool set(
const char* n);
61 const char*
code(
void) {
return (zcode ? zcode :
"??"); }
66 const char*
zone(
void) {
return (zoneval ? zoneval :
"Unknown"); }
72 unsigned long time(
void) {
return timeval; }
142 unsigned char dayval;
143 unsigned char monthval;
144 unsigned short yearval;
220 bool set(
unsigned short y,
unsigned char m,
unsigned char d,
DateType t = DATE_LOCAL);
233 bool system_set(
void);
239 unsigned char day(
void)
const {
return dayval; }
241 unsigned char month(
void)
const {
return monthval; }
243 unsigned short year(
void)
const {
return yearval; }
250 const char* day_name(
void);
257 const char* month_name(
void);
261 unsigned char days_in_month()
const;
267 unsigned char day_of_week()
const;
270 unsigned short day_of_year()
const;
282 Date operator++(
int);
292 Date operator--(
int);
300 static bool leap_year(
unsigned short y);
310 static unsigned char days_in_month(
unsigned short y,
unsigned char m);
320 static bool is_valid(
unsigned short y,
unsigned char m,
unsigned char d);
324 inline bool operator==(
const Date& d1,
const Date& d2)
325 {
return (d1.day() == d2.day() && d1.month() == d2.month() && d1.year() == d2.year()); }
327 inline bool operator>(
const Date& d1,
const Date& d2) {
328 return (d1.year() > d2.year() || (d1.year() == d2.year() && d1.month() > d2.month()) ||
329 (d1.year() == d2.year() && d1.month() == d2.month() && d1.day() > d2.day()));
332 inline bool operator!=(
const Date& d1,
const Date& d2) {
return !(d1 == d2); }
333 inline bool operator>=(
const Date& d1,
const Date& d2) {
return (d1 > d2 || d1 == d2); }
334 inline bool operator<(
const Date& d1,
const Date& d2) {
return (!(d1 > d2) && (d1 != d2)); }
335 inline bool operator<=(
const Date& d1,
const Date& d2) {
return (d1 == d2 || d1 < d2); }
351 unsigned char hourval;
352 unsigned char minval;
353 unsigned char secval;
384 void set(
unsigned char h,
unsigned char m,
unsigned char s = 0);
400 bool system_set(
void);
405 unsigned char hour(
void)
const {
return hourval; }
410 unsigned char minute(
void)
const {
return minval; }
415 unsigned char second(
void)
const {
return secval; }
428 Time operator++(
int);
438 Time operator--(
int);
448 static bool is_valid(
unsigned char h,
unsigned char m,
unsigned char s);
452 inline bool operator==(
const Time& t1,
const Time& t2) {
453 return (t1.hour() == t2.hour() && t1.minute() == t2.minute() && t1.second() == t2.second());
456 inline bool operator>(
const Time& t1,
const Time& t2) {
457 return (t1.hour() > t2.hour() ||
458 (t1.hour() == t2.hour() && t1.second() > t2.second()) ||
459 t1.second() == t2.second());
462 inline bool operator<(
const Time& t1,
const Time& t2) {
463 return (t1.hour() < t2.hour() ||
464 (t1.hour() == t2.hour() && t1.second() < t2.second()) ||
465 t1.second() == t2.second());
468 inline bool operator!=(
const Time& t1,
const Time& t2) {
return !(t1 == t2); }
469 inline bool operator>=(
const Time& t1,
const Time& t2) {
return (t1 > t2 || t1 == t2); }
470 inline bool operator<=(
const Time& t1,
const Time& t2) {
return (t1 == t2 || t1 < t2); }
A class for date manipulation.
Definition: DateTime.h:140
March.
Definition: DateTime.h:154
September.
Definition: DateTime.h:160
unsigned char second(void) const
Definition: DateTime.h:415
A class for time manipulation.
Definition: DateTime.h:349
May.
Definition: DateTime.h:156
Day
Current day.
Definition: DateTime.h:171
DateType
Types of date settable via Date::set()
Definition: DateTime.h:79
February.
Definition: DateTime.h:153
bool operator>(const String &str1, const char *str2)
Definition: String.h:365
unsigned char month(void) const
Definition: DateTime.h:241
bool operator==(const String &str1, const char *str2)
Definition: String.h:353
use UTC date
Definition: DateTime.h:81
use local date
Definition: DateTime.h:80
const char * zone(void)
Definition: DateTime.h:66
July.
Definition: DateTime.h:158
June.
Definition: DateTime.h:157
Year
Current year.
Definition: DateTime.h:179
December.
Definition: DateTime.h:163
April.
Definition: DateTime.h:155
bool leap_year(void) const
Definition: DateTime.h:236
unsigned char day(void) const
Definition: DateTime.h:239
bool operator<=(const String &str1, const char *str2)
Definition: String.h:383
unsigned char hour(void) const
Definition: DateTime.h:405
November.
Definition: DateTime.h:162
unsigned long time(void)
Definition: DateTime.h:72
October.
Definition: DateTime.h:161
August.
Definition: DateTime.h:159
unsigned short year(void) const
Definition: DateTime.h:243
bool operator!=(const String &str1, const char *str2)
Definition: String.h:359
Month
Abbreviated months.
Definition: DateTime.h:151
const char * code(void)
Definition: DateTime.h:61
bool operator<(const String &str1, const char *str2)
Definition: String.h:377
A class for getting time from desired time zone.
Definition: DateTime.h:32
bool operator>=(const String &str1, const char *str2)
Definition: String.h:371
unsigned char minute(void) const
Definition: DateTime.h:410