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);
239 unsigned char day(
void)
const {
return dayval; }
241 unsigned char month(
void)
const {
return monthval; }
243 unsigned short year(
void)
const {
return yearval; }
320 static bool is_valid(
unsigned short y,
unsigned char m,
unsigned char d);
327inline 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()));
332inline bool operator!=(
const Date& d1,
const Date& d2) {
return !(d1 == d2); }
333inline bool operator>=(
const Date& d1,
const Date& d2) {
return (d1 > d2 || d1 == d2); }
334inline bool operator<(
const Date& d1,
const Date& d2) {
return (!(d1 > d2) && (d1 != d2)); }
335inline 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);
405 unsigned char hour(
void)
const {
return hourval; }
410 unsigned char minute(
void)
const {
return minval; }
415 unsigned char second(
void)
const {
return secval; }
448 static bool is_valid(
unsigned char h,
unsigned char m,
unsigned char s);
456inline 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());
462inline 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());
468inline bool operator!=(
const Time& t1,
const Time& t2) {
return !(t1 == t2); }
469inline bool operator>=(
const Time& t1,
const Time& t2) {
return (t1 > t2 || t1 == t2); }
470inline bool operator<=(
const Time& t1,
const Time& t2) {
return (t1 == t2 || t1 < t2); }
A class for date manipulation.
Definition: DateTime.h:140
unsigned char month(void) const
Definition: DateTime.h:241
static bool is_valid(unsigned short y, unsigned char m, unsigned char d)
bool leap_year(void) const
Definition: DateTime.h:236
bool set(unsigned short y, unsigned char m, unsigned char d, DateType t=DATE_LOCAL)
unsigned char days_in_month() const
static unsigned char days_in_month(unsigned short y, unsigned char m)
Date & operator=(const Date &d)
unsigned short day_of_year() const
static bool leap_year(unsigned short y)
unsigned char day(void) const
Definition: DateTime.h:239
unsigned char day_of_week() const
Day
Current day.
Definition: DateTime.h:171
const char * month_name(void)
unsigned short year(void) const
Definition: DateTime.h:243
const char * day_name(void)
Month
Abbreviated months.
Definition: DateTime.h:151
@ Jul
July.
Definition: DateTime.h:158
@ Mar
March.
Definition: DateTime.h:154
@ Nov
November.
Definition: DateTime.h:162
@ Aug
August.
Definition: DateTime.h:159
@ Oct
October.
Definition: DateTime.h:161
@ Feb
February.
Definition: DateTime.h:153
@ Jun
June.
Definition: DateTime.h:157
@ Dec
December.
Definition: DateTime.h:163
@ May
May.
Definition: DateTime.h:156
@ Apr
April.
Definition: DateTime.h:155
@ Sep
September.
Definition: DateTime.h:160
Year
Current year.
Definition: DateTime.h:179
bool operator<(const String &str1, const char *str2)
Definition: String.h:377
bool operator>(const String &str1, const char *str2)
Definition: String.h:365
bool operator<=(const String &str1, const char *str2)
Definition: String.h:383
bool operator!=(const String &str1, const char *str2)
Definition: String.h:359
bool operator>=(const String &str1, const char *str2)
Definition: String.h:371
bool operator==(const String &str1, const char *str2)
Definition: String.h:353
A class for getting time from desired time zone.
Definition: DateTime.h:32
const char * code(void)
Definition: DateTime.h:61
unsigned long time(void)
Definition: DateTime.h:72
const char * zone(void)
Definition: DateTime.h:66
A class for time manipulation.
Definition: DateTime.h:349
static bool is_valid(unsigned char h, unsigned char m, unsigned char s)
void set(unsigned char h, unsigned char m, unsigned char s=0)
Time & operator=(const Time &t)
unsigned char hour(void) const
Definition: DateTime.h:405
unsigned char minute(void) const
Definition: DateTime.h:410
unsigned char second(void) const
Definition: DateTime.h:415
DateType
Types of date settable via Date::set()
Definition: DateTime.h:79
@ DATE_LOCAL
use local date
Definition: DateTime.h:80
@ DATE_UTC
use UTC date
Definition: DateTime.h:81