***********************
** FILE NAME : date.h
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.2 $
+** VERSION NUMBER : $Revision: 1.3 $
**
** DESCRIPTION :
**
/*****************************
$Log: date.h,v $
- Revision 1.2 2002-09-02 06:18:20 arjen
+ Revision 1.3 2002-09-28 06:58:45 arjen
+ Bugfix: conversion of an empty string to a date or hour object
+ now makes the values of such an object 0 (null) instead of giving
+ a segmentation fault.
+ The class UTC combines the date and hour classes. The most basic
+ functions of the UTC class are now implemented.
+ These include constructors and conversion to and from String objects.
+ New functions: date::proper(), hour::proper() and UTC::proper().
+ Return true if the object holds a proper clock time and/or calendar
+ date; false if at least one value is out of range.
+
+ Revision 1.2 2002/09/02 06:18:20 arjen
Fixed some date and time conversion functions
Revision 1.1 2002/07/25 08:01:26 arjen
*****************************/
-/* static const char *RCSID = "$Id: date.h,v 1.2 2002-09-02 06:18:20 arjen Exp $"; */
+/* static const char *RCSID = "$Id: date.h,v 1.3 2002-09-28 06:58:45 arjen Exp $"; */
#ifndef AXE_DATE_H
#define AXE_DATE_H
date subtract(unsigned long days);
+ friend class UTC;
+
public:
date()
date(String s);
+ bool proper(); // Check wether this is a proper calendar date
+
friend date operator+(date, date);
friend date operator+(unsigned long, date);
friend date operator+(date, unsigned long);
// date operator/(double)
// date& operator/=(double)
- friend ostream& operator<<(ostream&, const date&);
- friend istream& operator>>(istream&, date&);
+ friend std::ostream& operator<<(std::ostream&, const date&);
+ friend std::istream& operator>>(std::istream&, date&);
String format(const char *fmt = "%F");
};
int hours;
short minutes, seconds;
+ friend class UTC;
+
public:
hour()
hour(String s);
+ bool proper(); // Check wether this is a proper clock time
+
friend hour operator+(hour &, hour &);
hour operator += (hour h);
friend hour operator-(hour &, hour &);
- friend ostream& operator<<(ostream &, const hour &);
- friend istream& operator>>(istream &, hour &);
+ friend std::ostream& operator<<(std::ostream &, const hour &);
+ friend std::istream& operator>>(std::istream &, hour &);
String format(const char *fmt = "%T");
};
UTC()
{
+ /* Leave everything to the default hour and date constructors */
+ }
+
+ UTC(const String s);
+ UTC(date dt, hour tm)
+ {
+ d = dt;
+ t = tm;
+ }
+
+ operator date()
+ {
+ return d;
}
+
+ operator hour()
+ {
+ return t;
+ }
+
+ bool proper()
+ {
+ return d.proper() && t.proper();
+ }
+
+ friend std::ostream& operator<<(std::ostream &, const UTC &);
+ friend std::istream& operator>>(std::istream &, UTC &);
+
+ String format(const char *fmt = "%F %T");
};
+UTC Now();
+
#endif /* AXE_DATE_H */