.obj.eps:
tgif -print -eps -color $<
-XMLS = manual.xml string.xml date.xml hour.xml
+XMLS = manual.xml string.xml date.xml hour.xml utc.xml
IMAGES=
PICTURES=
xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="hour.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
+ <xi:include href="utc.xml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"/>
</book>
</doc>
--- /dev/null
+<chapter>
+<heading>UTC - Universal Time Coordinated class</heading>
+
+<pre>
+#include <date.h>
+
+UTC clock;
+</pre>
+
+<section>
+<heading>Construction and assignment</heading>
+<para>
+A UTC object can be constructed from its parts or by parsing from a String.
+<description>
+<item tag="UTC()">
+The default constructor creates a default of its parts.
+</item>
+<item tag="UTC(date d, hour t)">
+</item>
+<item tag="UTC(String s)">
+Parse the date and time from String s.
+</item>
+</description>
+</para>
+
+<description>
+<item tag="operator=(String &s)">
+Parse the date and time from String s.
+</item>
+</description>
+
+</section>
+
+<section>
+<heading>Conversion</heading>
+
+<para>
+String()
+</para>
+
+</section>
+
+<section>
+<heading>Relational operations</heading>
+
+<description>
+<item tag="operator==(UTC &)"></item>
+<item tag="operator!=(UTC &)"></item>
+<item tag="operator<(UTC &)"></item>
+<item tag="operator<=(UTC &)"></item>
+<item tag="operator>(UTC &)"></item>
+<item tag="operator>=(UTC &)"></item>
+</description>
+
+</section>
+
+<section>
+<heading>Attributes</heading>
+
+<h5>date day()</h5>
+<h5>hour hour()</h5>
+</section>
+
+<section>
+<heading>Arithmetic</heading>
+
+<description>
+<item tag="UTC operator+(UTC &t1, UTC &t2)"></item>
+<item tag="UTC operator-(UTC &t1, UTC &t2)"></item>
+<item tag="UTC &operator+=(UTC &t)"></item>
+<item tag="UTC &operator-=(UTC &t)"></item>
+<item tag="UTC &operator++()">
+Add one second.
+</item>
+<item tag="UTC &operator--()">
+Subtract one second.
+</item>
+</description>
+
+</section>
+
+<section>
+<heading>Stream I/O</heading>
+
+<description>
+<item tag="ostream &operator<<(ostream &str, UTC &t)">
+Write the date and time to the output stream in the default format.
+</item>
+<item tag="istream &operator>>(istream &str, UTC &t)">
+Scan the input stream for a date and time.
+</item>
+</description>
+</section>
+
+</chapter>
lib_LTLIBRARIES = libACL.la
libACL_la_SOURCES = string.cpp regex.cpp date.cpp parsedate.c dateyacc.y datelex.c \
- hour.cpp
+ hour.cpp utc.cpp
include_HEADERS = String.h date.h
return d.proper() && t.proper();
}
+ bool operator==(UTC u)
+ {
+ return d == u.d && t == u.t;
+ }
+
+ bool operator!=(UTC u)
+ {
+ return d != u.d || t != u.t;
+ }
+
+ bool operator<=(UTC u)
+ {
+ if (d == u.d)
+ {
+ return t <= u.t;
+ }
+ else
+ {
+ return d <= u.d;
+ }
+ }
+
+ bool operator<(UTC u)
+ {
+ if (d == u.d)
+ {
+ return t < u.t;
+ }
+ else
+ {
+ return d < u.d;
+ }
+ }
+
+ bool operator>=(UTC u)
+ {
+ if (d == u.d)
+ {
+ return t >= u.t;
+ }
+ else
+ {
+ return d >= u.d;
+ }
+ }
+
+ bool operator>(UTC u)
+ {
+ if (d == u.d)
+ {
+ return t > u.t;
+ }
+ else
+ {
+ return d > u.d;
+ }
+ }
+
+ friend UTC operator+(UTC &, UTC &);
+ UTC operator += (UTC h);
+
friend std::ostream& operator<<(std::ostream &, const UTC &);
friend std::istream& operator>>(std::istream &, UTC &);
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_arithmetic hour_check_now
+ hour_assign hour_parse hour_compare hour_arithmetic hour_check_now \
+ utc_assign utc_compare
string_assign_SOURCES = string_assign.cpp
string_basics_SOURCES = string_basics.cpp
hour_check_now_SOURCES = hour_check_now.cpp
hour_now : hour_check_now
+utc_assign_SOURCES = utc_assign.cpp
+utc_compare_SOURCES = utc_compare.cpp
--- /dev/null
+09-06-2019 Day = 9
+09-06-2019 Month = 6
+09-06-2019 Monthname = Jun
+09-06-2019 Year = 2019
+09-06-2019 Leap = 0
+09-06-2020 Leap = 1
+09-06-2000 Leap = 1
+09-06-2100 Leap = 0
+Jan 2019 has 31 days.
+Feb 2019 has 28 days.
+Feb 2020 has 29 days.
+PASS date_attributes (exit status: 0)
--- /dev/null
+/*******************************************************
+ * Unit test for the UTC class
+ *
+ * test contrustor and assignment of UTC objects
+ ******************************************************
+ *
+ */
+
+#include "date.h"
+#include <assert.h>
+
+int main()
+{
+ // Default contructor: all zero
+ UTC u0;
+ date d0;
+ hour h0;
+
+ d0 = date(u0);
+ h0 = hour(u0);
+
+ std::cout << "The default contructor makes a zero date:and time " << u0 << "\n";
+ assert(d0.Day() == 0);
+ assert(d0.Month() == 0);
+ assert(d0.Year() == 0);
+ assert(h0.Hour() == 0);
+ assert(h0.Minute() == 0);
+ assert(h0.Second() == 0);
+
+ date d1(15, 9, 2002);
+ hour h1(15, 23, 46);
+
+ UTC u1(d1, h1);
+
+ std::cout << "Contructor with date = 15-9-2002, hour = 15:23:46: " << u1 << "\n";
+ date d2(u1);
+ hour h2(u1);
+
+ assert(d2.Day() == 15);
+ assert(d2.Month() == 9);
+ assert(d2.Year() == 2002);
+ assert(h2.Hour() == 15);
+ assert(h2.Minute() == 23);
+ assert(h2.Second() == 46);
+
+ String s3("23-10-2019 23:45:16");
+ UTC u3(s3);
+
+ std::cout << "Contructor from String " << s3 << " : " << u3 << "\n";
+
+ date d3(u3);
+ hour h3(u3);
+
+ assert(d3.Day() == 23);
+ assert(d3.Month() == 10);
+ assert(d3.Year() == 2019);
+ assert(h3.Hour() == 23);
+ assert(h3.Minute() == 45);
+ assert(h3.Second() == 16);
+
+ String s4("Thu Oct 3 22:38:38 CEST 2019");
+ UTC u4(s4);
+
+ std::cout << "Contructor from String " << s4 << " : " << u4 << "\n";
+
+ date d4(u4);
+ hour h4(u4);
+
+ assert(d4.Day() == 3);
+ assert(d4.Month() == 10);
+ assert(d4.Year() == 2019);
+ assert(h4.Hour() == 22);
+ assert(h4.Minute() == 38);
+ assert(h4.Second() == 38);
+
+ return 0;
+}
+
--- /dev/null
+The default contructor makes a zero date:and time 00-00-0 00:00:00
+Contructor with date = 15-9-2002, hour = 15:23:46: 15-09-2002 15:23:46
+Contructor from String 23-10-2019 23:45:16 : 23-10-2019 23:45:16
+Contructor from String Thu Oct 3 22:38:38 CEST 2019 : 03-10-2019 22:38:38
+PASS utc_assign (exit status: 0)
--- /dev/null
+/*******************************************************
+ * Unit test for the UTC class
+ *
+ * test UTC relational operators
+ ******************************************************
+ *
+ */
+
+#include "date.h"
+#include <assert.h>
+
+int main()
+{
+ UTC u0("9-6-2019 11:22:00");
+ UTC u1("9-6-2019 11:22:00");
+ UTC u2("9-6-2019 11:22:01");
+ UTC u3("7-8-2019 11:22:00");
+
+ // equal dates
+
+ std::cout << u0 << " == " << u1 << " = " << (u0 == u1) << "\n";
+ assert((u0 == u1) == true);
+
+ std::cout << u0 << " != " << u1 << " = " << (u0 != u1) << "\n";
+ assert((u0 != u1) == false);
+
+ std::cout << u0 << " < " << u1 << " = " << (u0 < u1) << "\n";
+ assert((u0 < u1) == false);
+
+ std::cout << u0 << " <= " << u1 << " = " << (u0 <= u1) << "\n";
+ assert((u0 <= u1) == true);
+
+ std::cout << u0 << " > " << u1 << " = " << (u0 > u1) << "\n";
+ assert((u0 > u1) == false);
+
+ std::cout << u0 << " >= " << u1 << " = " << (u0 >= u1) << "\n";
+ assert((u0 >= u1) == true);
+
+ // unequal dates
+
+ std::cout << u0 << " == " << u2 << " = " << (u0 == u2) << "\n";
+ assert((u0 == u2) == false);
+
+ std::cout << u0 << " != " << u2 << " = " << (u0 != u2) << "\n";
+ assert((u0 != u2) == true);
+
+ std::cout << u0 << " < " << u2 << " = " << (u0 < u2) << "\n";
+ assert((u0 < u2) == true);
+
+ std::cout << u0 << " <= " << u2 << " = " << (u0 <= u2) << "\n";
+ assert((u0 <= u2) == true);
+
+ std::cout << u0 << " > " << u2 << " = " << (u0 > u2) << "\n";
+ assert((u0 > u2) == false);
+
+ std::cout << u0 << " >= " << u2 << " = " << (u0 >= u2) << "\n";
+ assert((u0 >= u2) == false);
+
+ std::cout << u0 << " == " << u3 << " = " << (u0 == u3) << "\n";
+ assert((u0 == u3) == false);
+
+ std::cout << u0 << " != " << u3 << " = " << (u0 != u3) << "\n";
+ assert((u0 != u3) == true);
+
+ std::cout << u0 << " < " << u3 << " = " << (u0 < u3) << "\n";
+ assert((u0 < u3) == true);
+
+ std::cout << u0 << " <= " << u3 << " = " << (u0 <= u3) << "\n";
+ assert((u0 <= u3) == true);
+
+ std::cout << u0 << " > " << u3 << " = " << (u0 > u3) << "\n";
+ assert((u0 > u3) == false);
+
+ std::cout << u0 << " >= " << u3 << " = " << (u0 >= u3) << "\n";
+ assert((u0 >= u3) == false);
+
+ return 0;
+}
+
--- /dev/null
+09-06-2019 11:22:00 == 09-06-2019 11:22:00 = 1
+09-06-2019 11:22:00 != 09-06-2019 11:22:00 = 0
+09-06-2019 11:22:00 < 09-06-2019 11:22:00 = 0
+09-06-2019 11:22:00 <= 09-06-2019 11:22:00 = 1
+09-06-2019 11:22:00 > 09-06-2019 11:22:00 = 0
+09-06-2019 11:22:00 >= 09-06-2019 11:22:00 = 1
+09-06-2019 11:22:00 == 09-06-2019 11:22:01 = 0
+09-06-2019 11:22:00 != 09-06-2019 11:22:01 = 1
+09-06-2019 11:22:00 < 09-06-2019 11:22:01 = 1
+09-06-2019 11:22:00 <= 09-06-2019 11:22:01 = 1
+09-06-2019 11:22:00 > 09-06-2019 11:22:01 = 0
+09-06-2019 11:22:00 >= 09-06-2019 11:22:01 = 0
+09-06-2019 11:22:00 == 07-08-2019 11:22:00 = 0
+09-06-2019 11:22:00 != 07-08-2019 11:22:00 = 1
+09-06-2019 11:22:00 < 07-08-2019 11:22:00 = 1
+09-06-2019 11:22:00 <= 07-08-2019 11:22:00 = 1
+09-06-2019 11:22:00 > 07-08-2019 11:22:00 = 0
+09-06-2019 11:22:00 >= 07-08-2019 11:22:00 = 0
+PASS utc_compare (exit status: 0)