Added documentation for class hour.
authorArjen Baart <arjen@andromeda.nl>
Sat, 6 Jul 2019 07:25:28 +0000 (09:25 +0200)
committerArjen Baart <arjen@andromeda.nl>
Sat, 6 Jul 2019 07:25:28 +0000 (09:25 +0200)
doc/Makefile.am
doc/date.xml
doc/hour.xml [new file with mode: 0644]
doc/manual.xml

index e3e9399..200bf0c 100644 (file)
@@ -7,7 +7,7 @@ SUFFIXES = .obj .eps .png
 .obj.eps:
        tgif -print -eps -color $<
 
-XMLS = manual.xml string.xml date.xml
+XMLS = manual.xml string.xml date.xml hour.xml
 IMAGES=
 
 PICTURES=
index 40d038d..50a9579 100644 (file)
@@ -7,12 +7,37 @@
 date d;
 </pre>
 <para>
-The <emph>date</emph> class encapsulates the concept of a calender date. It holds
+The <emph>date</emph> class encapsulates the concept of a date, represented by
+days, months and years. It holds
 a day and a month, both between 0 and 255, and a year ranging from -32768 to
 +32767. Although full-range dates can be usefull in calulations, a real date
 should have a day between 1 and 31 inclusive, and a month between 1 and 12.
+Only such dates can be used as proper calender dates.
+A different kind of date may be used as a relative date to perform calculations.
+For example, to add 2 years, 3 months and 6 days to a date, a date like (6, 3, 2) can be created.
 All calculations with dates are based on the Julian calendar.
 </para>
+<para>
+Parsing text into a date object is a challenging task.
+Partly because there are many ways to write dates but also because some
+ways to write a date are ambiguous.
+For example, the date 8-2-12 could mean August 2nd 2012, 12th of February 2008
+or 8th of February 2012.
+These are some ways to write February 8th 2012 that are supported by the parser:
+<itemize>
+<item>20120208</item>
+<item>2012-02-08</item>
+<item>2012 02 08</item>
+<item>08-02-2012</item>
+<item>02/08/2012</item>
+<item>Feb 8 2012</item>
+<item>2012 Feb 8</item>
+<item>8 FEB 2012</item>
+<item>2012 8 feb</item>
+<item>8 February 2012</item>
+</itemize>
+
+</para>
 
 <section>
 <heading>Construction</heading>
@@ -21,8 +46,11 @@ All calculations with dates are based on the Julian calendar.
 The default constructor sets all elements (day, month and year) to 0.
 </item>
 <item tag="date(unsigned day, unsigned month=0, short year=0)">
+Constructs a date object with the specified year, month and day.
+For this date object to be a proper calendar date, the month must be between
+1 and 12 an the day myst be between 1 and the number of days in that month.
 </item>
-<item tag=">date(unsigned day, string month, short year)">
+<item tag="date(unsigned day, string month, short year)">
 </item>
 <item tag="date(string s)">
 </item>
@@ -34,7 +62,8 @@ The default constructor sets all elements (day, month and year) to 0.
 <description>
 <item tag="operator=(date &amp;d)">
 </item>
-<item tag=">operator=(string &amp;s)">
+<item tag="operator=(string &amp;s)">
+Parse string s and extract a day, month and year if the string contains an actual date.
 </item>
 </description>
 </section>
@@ -55,6 +84,9 @@ Converts a date to an ASCII format.
 
 <section>
 <heading>Relational operations</heading>
+<para>
+The relational operators are defined with obvious meanings:
+</para>
 <description>
 <item tag="operator==(date d)">
 </item>
@@ -96,11 +128,16 @@ Returns the number of days in this month, or zero if the month is not
 between 1 and 12.
 </item>
 <item tag="unsigned WeekDay()">
+Calculate the day of the week, where 1 is Monday and 7 is Sunday.
+If the date is not a proper calendar date, return 0.
 </item>
 <item tag="string DayName()">
 </item>
 <item tag="string MonthName()">
 </item>
+<item tag="string WeekNumber()">
+Calculate the number of the week within the year.
+</item>
 </description>
 </section>
 
@@ -109,10 +146,14 @@ between 1 and 12.
 <heading>Arithmetic</heading>
 <description>
 <item tag="date operator+(date &amp;d1, date &amp;d2)">
+Add a number of days, months and years to a date.
+This is most usefull if one of the dates is a proper calendar date
+and the other is not.
 </item>
 <item tag="date operator+=(date &amp;d)">
 </item>
 <item tag="date operator+(long l, date &amp;d)">
+Add a number of days to a date.
 </item>
 <item tag="date operator+(date &amp;d, long l)">
 </item>
diff --git a/doc/hour.xml b/doc/hour.xml
new file mode 100644 (file)
index 0000000..e1c4cd1
--- /dev/null
@@ -0,0 +1,130 @@
+<?xml version='1.0'?>
+<chapter>
+
+<heading> hour - Time class </heading>
+<pre>
+#include &lt;date.h&gt;
+
+hour t;
+</pre>
+<para>
+The <emph>hour</emph> class encapsulates a time in hours, minutes and seconds.
+Most operators are defined to provide calculations just like integer numbers.
+</para>
+
+<section>
+<heading>Construction and assigment</heading>
+
+<para>
+Objects of class <emph>hour</emph> can be constructed and assigned from integer numbers,
+String objects or other hour objects.
+</para>
+<description>
+<item tag='hour()'>
+</item>
+<item tag='hour(long)'>
+A number of seconds.
+</item>
+<item tag='hour(int hour, short minute, short second)'>
+</item>
+<item tag='hour(const String)'>
+
+Format is HH:MM:SS
+
+</item>
+
+<item tag='operator=(hour &amp;)'>
+</item>
+<item tag='operator=(string &amp;)'>
+</item>
+<item tag='operator=(long)'>
+</item>
+</description>
+
+</section>
+
+<section>
+<heading>Conversion</heading>
+
+<description>
+<item tag='long()'>
+
+Converts to a number of seconds.
+</item>
+
+<item tag='String()'>
+</item>
+</description>
+
+</section>
+<section>
+<heading>Relational operations</heading>
+
+<description>
+<item tag='operator==(hour &amp;)'>
+</item>
+<item tag='>operator!=(hour &amp;)'>
+</item>
+<item tag='operator&lt;(hour &amp;)'>
+</item>
+<item tag='operator&lt;=(hour &amp;)'>
+</item>
+<item tag='operator&gt;(hour &amp;)'>
+</item>
+<item tag='operator&gt;=(hour &amp;)'>
+</item>
+</description>
+
+</section>
+<section>
+<heading>Attributes</heading>
+
+<description>
+<item tag='int hour()'>
+</item>
+<item tag='short minute()'>
+</item>
+<item tag='short second()'>
+</item>
+</description>
+
+</section>
+<section>
+<heading>Arithmetic</heading>
+
+<description>
+<item tag='hour operator+(hour &amp;t1, hour &amp;t2)'>
+</item>
+<item tag='hour operator-(hour &amp;t1, hour &amp;t2)'>
+</item>
+<item tag='hour &amp;operator+=(hour &amp;t)'>
+</item>
+<item tag='hour &amp;operator-=(hour &amp;t)'>
+</item>
+<item tag='hour &amp;operator++()'>
+</item>
+<item tag='hour &amp;operator--()'>
+</item>
+</description>
+
+</section>
+<section>
+<heading>Stream I/O</heading>
+
+<description>
+<item tag='ostream &amp;operator&lt;&lt;(ostream &amp;str, hour &amp;t)'>
+</item>
+<item tag='istream &amp;operator&gt;&gt;(istream &amp;str, hour &amp;t)'>
+</item>
+</description>
+
+</section>
+<section>
+<heading> SEE ALSO</heading>
+
+<a href="date.html">date</a>
+<a href="UTC.html">UTC</a>
+
+
+</section>
+</chapter>
index a1020ab..d1ce759 100644 (file)
@@ -9,5 +9,7 @@
          xmlns:xi="http://www.w3.org/2001/XInclude"/>
     <xi:include href="date.xml"
          xmlns:xi="http://www.w3.org/2001/XInclude"/>
+    <xi:include href="hour.xml"
+         xmlns:xi="http://www.w3.org/2001/XInclude"/>
   </book>
 </doc>