+Sep 02, 2002 - Patch 0.2.2
+--------------------------
+
+ - date::format() is now properly implemented
+ - New operator to read an 'hour' object from an istream:
+ istream & operator >> (istream &, hour &)
+ - New function 'String hour::format()'. The default format is HH:MM:SS
+ in 24 hour clock.
+ - New function 'hour now()' read the current time of day.
+
Jul 27, 2002 - Patch 0.2.1
---------------------------
***********************
** FILE NAME : acltest.cpp
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.2 $
+** VERSION NUMBER : $Revision: 1.3 $
**
** DESCRIPTION : Test routine for non-X classes
**
/*****************************
$Log: acltest.cpp,v $
- Revision 1.2 2002-07-27 06:34:06 arjen
+ Revision 1.3 2002-09-02 06:18:12 arjen
+ Fixed some date and time conversion functions
+
+ Revision 1.2 2002/07/27 06:34:06 arjen
Removed the obsolete complex number test from acltest.
BUG FIX: testaxe crashed when no configuration file is available.
*****************************/
-static const char *RCSID = "$Id: acltest.cpp,v 1.2 2002-07-27 06:34:06 arjen Exp $";
+static const char *RCSID = "$Id: acltest.cpp,v 1.3 2002-09-02 06:18:12 arjen Exp $";
#include "String.h"
#include "integer.h"
cout << "c = b : c = " << c << "\n";
cout << "***********************\nDate Test\n*********************\n";
+
date d1, d2(22,7,1964);
cout << "Default constructor: " << d1 << ", with (d,m,y): " << d2 << "\n";
d2 = date(datestring);
cout << datestring << " parses into (DD-MM-YYYY): " << d2 << "\n";
- datestring = d2.format();
+ datestring = d2.format("%F");
cout << "Formatted date: " << datestring << "\n";
d1 = today();
cout << "t1 - t2 = " << t1 - t2 << "\n";
cout << "t2 - t1 = " << t2 - t1 << "\n";
+ d1 = today();
+ t1 = now();
+
+ cout << "\nThe time now is " << d1 << " " << t1 << "\n";
return 0;
}
***********************
** FILE NAME : configuration.h
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION : Definition of configuration class
**
/*****************************
$Log: configuration.h,v $
- Revision 1.1 2002-07-25 08:01:26 arjen
+ 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
First checkin, AXE release 0.2
*****************************/
-/* static const char *RCSID = "$Id: configuration.h,v 1.1 2002-07-25 08:01:26 arjen Exp $"; */
+/* static const char *RCSID = "$Id: configuration.h,v 1.2 2002-09-02 06:18:20 arjen Exp $"; */
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
// MEMBERS :
// OPERATORS :
// METHODS : read
+// find_parameter
//
// DESCRIPTION : Handle configurational parameters for the application.
// Many applications need some permanently stored configurational
// wide configuration file and a configuration file per user.
// The content of the configuration file is in XML format.
// The configuration base class takes care of finding the configuration
-// files, e.g. in /etc/app.conf or in /usr/loca/etc/app.conf, along
+// files, e.g. in /etc/app.conf or in /usr/local/etc/app.conf, along
// with the configuration file in the user's home directory.
// The config files are parsed with the gnome XML parser and a
// framework is provided to find configurational items.
***********************
** FILE NAME : date.cpp
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION :
**
/*****************************
$Log: date.cpp,v $
- Revision 1.1 2002-07-25 08:01:26 arjen
+ 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
First checkin, AXE release 0.2
*****************************/
-static const char *RCSID = "$Id: date.cpp,v 1.1 2002-07-25 08:01:26 arjen Exp $";
+static const char *RCSID = "$Id: date.cpp,v 1.2 2002-09-02 06:18:20 arjen Exp $";
#include <iostream>
#include <time.h>
String date::format(const char *fmt)
{
String s;
- //char buf[40];
+ char buf[40];
struct tm t;
- t.tm_year = year;
- t.tm_mon = month;
+ t.tm_year = year - 1900;
+ t.tm_mon = month - 1;
t.tm_mday = day;
- s = String(int(day)) + String(" ") + MonthName() + String(" ") + String(year);
- //strftime(buf, 40, fmt, &t);
- //s = buf;
+ strftime(buf, 40, fmt, &t);
+ s = buf;
return s;
}
***********************
** FILE NAME : date.h
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION :
**
/*****************************
$Log: date.h,v $
- Revision 1.1 2002-07-25 08:01:26 arjen
+ 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
First checkin, AXE release 0.2
*****************************/
-/* static const char *RCSID = "$Id: date.h,v 1.1 2002-07-25 08:01:26 arjen Exp $"; */
+/* static const char *RCSID = "$Id: date.h,v 1.2 2002-09-02 06:18:20 arjen Exp $"; */
#ifndef AXE_DATE_H
#define AXE_DATE_H
friend ostream& operator<<(ostream&, const date&);
friend istream& operator>>(istream&, date&);
- String format(const char *fmt = "%x");
+ String format(const char *fmt = "%F");
};
-date today(void);
+date today();
class hour
{
friend hour operator-(hour &, hour &);
friend ostream& operator<<(ostream &, const hour &);
+ friend istream& operator>>(istream &, hour &);
+
+ String format(const char *fmt = "%T");
};
+hour now();
+
class UTC
{
hour t;
***********************
** FILE NAME : hour.cpp
** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
-** VERSION NUMBER : $Revision: 1.1 $
+** VERSION NUMBER : $Revision: 1.2 $
**
** DESCRIPTION :
**
/*****************************
$Log: hour.cpp,v $
- Revision 1.1 2002-07-25 08:01:27 arjen
+ 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:27 arjen
First checkin, AXE release 0.2
*****************************/
-static const char *RCSID = "$Id: hour.cpp,v 1.1 2002-07-25 08:01:27 arjen Exp $";
+static const char *RCSID = "$Id: hour.cpp,v 1.2 2002-09-02 06:18:20 arjen Exp $";
+
+#include <time.h>
#include "date.h"
#include "parsedate.h"
seconds = pd->second;
}
+hour now()
+{
+ long clock;
+ struct tm *tp;
+
+ time(&clock);
+ tp = localtime(&clock);
+
+ return hour(tp->tm_hour, tp->tm_min, tp->tm_sec);
+}
+
hour operator+(hour &t1, hour &t2)
{
hour t = t1;
ostream& operator<<(ostream &s, const hour &t)
{
- s << t.hours << ":" << t.minutes << ":" << t.seconds;
+ s.width(2);
+ s.fill('0');
+ s << t.hours << ":";
+ s.width(2);
+ s.fill('0');
+ s << t.minutes << ":";
+ s.width(2);
+ s.fill('0');
+ s << t.seconds;
+
+ return s;
+}
+
+istream &operator>>(istream &s, hour &h)
+{
+ char c;
+ int H, M, S;
+
+ s >> H >> c >> M >> c >> S;
+
+ h.hours = H;
+ h.minutes = M;
+ h.seconds = S;
+
+ return s;
+}
+
+String hour::format(const char *fmt)
+{
+ String s;
+ char buf[40];
+ struct tm t;
+
+ t.tm_sec = seconds;
+ t.tm_min = minutes;
+ t.tm_hour = hours;
+
+ strftime(buf, 40, fmt, &t);
+ s = buf;
return s;
}