-May 30, 2019 - Release 0.1
+Aug 29, 2019 - Release 0.3
============================
- - Extracted the classes not related to X windows from AXE
- - Implemented and brushed up the String class.
+ - Implemented hour class
Jun 22, 2019 - Release 0.2
============================
- Added date class
+
+May 30, 2019 - Release 0.1
+============================
+
+ - Extracted the classes not related to X windows from AXE
+ - Implemented and brushed up the String class.
+
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
-AC_INIT([libACL], [0.2], [arjen@androemda.nl])
+AC_INIT([libACL], [0.3], [arjen@androemda.nl])
AM_INIT_AUTOMAKE([-Wall foreign])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_FILES([Makefile src/Makefile test/Makefile doc/Makefile])
return cm;
}
+ hour increase();
+ hour decrease();
+
public:
hour()
friend hour operator+(hour &, hour &);
hour operator += (hour h);
+
+ hour operator ++ () // prefix
+ {
+ return increase();
+ }
+
+ hour operator ++ (int) // postfix
+ {
+ return increase();
+ }
+
friend hour operator-(hour &, hour &);
+ hour operator -= (hour h);
+
+ hour operator -- () // prefix
+ {
+ return decrease();
+ }
+
+ hour operator -- (int) // postfix
+ {
+ return decrease();
+ }
+
friend std::ostream& operator<<(std::ostream &, const hour &);
friend std::istream& operator>>(std::istream &, hour &);
/*$Log: datelex.c,v $
-/*Revision 1.2 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-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.1 2002/07/25 08:01:26 arjen
*First checkin, AXE release 0.2
*
return *this;
}
+hour hour::increase()
+{
+ seconds ++;
+ if (seconds >= 60)
+ {
+ minutes++;
+ seconds -= 60;
+ }
+ if (minutes >= 60)
+ {
+ hours++;
+ minutes -= 60;
+ }
+
+ return *this;
+}
+
hour operator-(hour &t1, hour &t2)
{
hour t = t1;
return t;
}
+hour hour::operator-=(hour t)
+{
+ seconds -= t.seconds;
+ if (seconds < 0)
+ {
+ minutes--;
+ seconds += 60;
+ }
+
+ minutes -= t.minutes;
+ if (minutes < 0)
+ {
+ hours--;
+ minutes += 60;
+ }
+
+ hours -= t.hours;
+
+ return *this;
+}
+
+hour hour::decrease()
+{
+ seconds --;
+ if (seconds < 0)
+ {
+ minutes--;
+ seconds += 60;
+ }
+
+ if (minutes < 0)
+ {
+ hours--;
+ minutes += 60;
+ }
+
+ return *this;
+}
+
std::ostream& operator<<(std::ostream &s, const hour &t)
{
s.width(2);
LDADD = ../src/.libs/libACL.la
check_PROGRAMS = string_assign string_basics string_compare string_cat string_substring string_regex \
date_assign date_parse date_compare date_arithmetic date_attributes date_check_today \
- hour_assign hour_parse hour_compare
+ hour_assign hour_parse hour_compare hour_arithmetic
string_assign_SOURCES = string_assign.cpp
string_basics_SOURCES = string_basics.cpp
hour_assign_SOURCES = hour_assign.cpp
hour_parse_SOURCES = hour_parse.cpp
hour_compare_SOURCES = hour_compare.cpp
+hour_arithmetic_SOURCES = hour_arithmetic.cpp
--- /dev/null
+/*******************************************************
+ * Unit test for the hour class
+ *
+ * test hour add and subtract expressions
+ ******************************************************
+ *
+ */
+
+#include "date.h"
+#include <assert.h>
+
+int main()
+{
+ hour h0(14, 22, 45);
+ hour period0(11, 45, 30);
+
+ hour h2;
+ h2 = h0 + period0;
+
+ std::cout << h0 << " + " << period0 << " = " << h2 << "\n";
+ assert(h2 == hour(26, 8, 15));
+
+ std::cout << h0 << " += " << period0 << " = ";
+ h0 += period0;
+ std::cout << h0 << "\n";
+ assert(h0 == hour(26, 8, 15));
+
+ // 11:05:30 - 1:20:40 = 9:44:50
+ hour h1(11, 5, 30);
+ hour period1(1, 20, 40);
+ h2 = h1 - period1;
+
+ std::cout << h1 << " - " << period1 << " = " << h2 << "\n";
+ assert(h2 == hour(9, 44, 50));
+
+ std::cout << h1 << " -= " << period1 << " = ";
+ h1 -= period1;
+ std::cout << h1 << "\n";
+ std::cout.flush();
+ assert(h1 == hour(9, 44, 50));
+
+ // The increment operator
+
+ hour h3(22, 59, 59);
+ std::cout << h3 << "++ = ";
+ h3++;
+ std::cout << h3 << "\n";
+ assert(h3 == hour(23, 0, 0));
+
+ hour h4(22, 59, 59);
+ std::cout << "++" << h4 << " = ";
+ ++h4;
+ std::cout << h4 << "\n";
+ assert(h4 == hour(23, 0, 0));
+
+ // The decrement operator
+
+ hour h5(22, 0, 0);
+ std::cout << h5 << "-- = ";
+ h5--;
+ std::cout << h5 << "\n";
+ assert(h5 == hour(21, 59, 59));
+
+ hour h6(22, 0, 0);
+ std::cout << "--" << h6 << " = ";
+ --h6;
+ std::cout << h6 << "\n";
+ assert(h6 == hour(21, 59, 59));
+
+ return 0;
+}
+
--- /dev/null
+14:22:45 + 11:45:30 = 26:08:15
+14:22:45 += 11:45:30 = 26:08:15
+11:05:30 - 01:20:40 = 09:44:50
+11:05:30 -= 01:20:40 = 09:44:50
+22:59:59++ = 23:00:00
+++22:59:59 = 23:00:00
+22:00:00-- = 21:59:59
+--22:00:00 = 21:59:59
+PASS hour_arithmetic (exit status: 0)