1 /**************************************************************************
2 ** (c) Copyright 1999, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
7 ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
8 ** VERSION NUMBER : $Revision: 1.3 $
15 ***************************************************************************
16 ** ADMINISTRATIVE INFORMATION *
17 ********************************
18 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 ** CREATION DATE : Feb 06, 1998
20 ** LAST UPDATE : Oct 16, 1999
22 **************************************************************************/
24 /*****************************
26 Revision 1.3 2002-09-28 06:58:45 arjen
27 Bugfix: conversion of an empty string to a date or hour object
28 now makes the values of such an object 0 (null) instead of giving
30 The class UTC combines the date and hour classes. The most basic
31 functions of the UTC class are now implemented.
32 These include constructors and conversion to and from String objects.
33 New functions: date::proper(), hour::proper() and UTC::proper().
34 Return true if the object holds a proper clock time and/or calendar
35 date; false if at least one value is out of range.
37 Revision 1.2 2002/09/02 06:18:20 arjen
38 Fixed some date and time conversion functions
40 Revision 1.1 2002/07/25 08:01:26 arjen
41 First checkin, AXE release 0.2
43 *****************************/
45 /* static const char *RCSID = "$Id: date.h,v 1.3 2002-09-28 06:58:45 arjen Exp $"; */
54 unsigned char month, day;
59 date add(unsigned long days);
61 date subtract(unsigned long days);
74 date(unsigned d, unsigned m=0, short y=0)
83 bool proper(); // Check wether this is a proper calendar date
85 friend date operator+(date, date);
86 friend date operator+(unsigned long, date);
87 friend date operator+(date, unsigned long);
89 date operator += (date D)
94 date operator += (unsigned long l)
99 friend date operator-(unsigned long, date);
100 friend date operator-(date, unsigned long);
101 friend long operator-(date&, date&);
103 date operator -= (unsigned long l)
108 // long(date); // Calculate nr. of days since...
110 int operator==(date d)
114 cm = this->year - d.year;
115 cm = (cm != 0) ? cm : this->month - d.month;
116 cm = (cm != 0) ? cm : this->day - d.day;
121 int operator!=(date d)
125 cm = this->year - d.year;
126 cm = (cm != 0) ? cm : this->month - d.month;
127 cm = (cm != 0) ? cm : this->day - d.day;
132 int operator<=(date d)
136 cm = this->year - d.year;
137 cm = (cm != 0) ? cm : this->month - d.month;
138 cm = (cm != 0) ? cm : this->day - d.day;
143 int operator>=(date d)
147 cm = this->year - d.year;
148 cm = (cm != 0) ? cm : this->month - d.month;
149 cm = (cm != 0) ? cm : this->day - d.day;
154 int operator>(date d)
158 cm = this->year - d.year;
159 cm = (cm != 0) ? cm : this->month - d.month;
160 cm = (cm != 0) ? cm : this->day - d.day;
165 int operator<(date d)
169 cm = this->year - d.year;
170 cm = (cm != 0) ? cm : this->month - d.month;
171 cm = (cm != 0) ? cm : this->day - d.day;
188 String MonthName(void);
197 unsigned DaysInMonth();
199 // date operator*(double)
200 // date& operator*=(double)
201 // date operator/(double)
202 // date& operator/=(double)
204 friend std::ostream& operator<<(std::ostream&, const date&);
205 friend std::istream& operator>>(std::istream&, date&);
207 String format(const char *fmt = "%F");
215 short minutes, seconds;
228 hour(int hr, short minute, short sec)
237 bool proper(); // Check wether this is a proper clock time
239 friend hour operator+(hour &, hour &);
240 hour operator += (hour h);
241 friend hour operator-(hour &, hour &);
243 friend std::ostream& operator<<(std::ostream &, const hour &);
244 friend std::istream& operator>>(std::istream &, hour &);
246 String format(const char *fmt = "%T");
260 /* Leave everything to the default hour and date constructors */
264 UTC(date dt, hour tm)
282 return d.proper() && t.proper();
285 friend std::ostream& operator<<(std::ostream &, const UTC &);
286 friend std::istream& operator>>(std::istream &, UTC &);
288 String format(const char *fmt = "%F %T");
293 #endif /* AXE_DATE_H */