Compare commits

...

13 Commits

Author SHA1 Message Date
nobody aa11276f52 This commit was manufactured by cvs2svn to create tag
'Version_1_31_0'.

[SVN r22162]
2004-02-04 15:24:32 +00:00
Jeff Garland 9703bded9a update compiler status summary and limitation info
[SVN r22125]
2004-02-01 23:27:08 +00:00
Jeff Garland d698b6cd3b additional acknowledgements
[SVN r22123]
2004-02-01 22:41:00 +00:00
Jeff Garland 00a491e214 cleanup of licensing links
[SVN r22116]
2004-02-01 19:08:14 +00:00
Jeff Garland b86a02c9c6 a couple minor documentation updates
[SVN r22109]
2004-02-01 18:01:04 +00:00
Jeff Garland 2e6cdea14e various updates for 1.31 release
[SVN r21834]
2004-01-20 04:58:22 +00:00
Jeff Garland 14b94f3ab6 fix doc for span
[SVN r21827]
2004-01-18 21:43:50 +00:00
Jeff Garland 3aedb84eff update for bi-directional changes
[SVN r21825]
2004-01-18 21:34:56 +00:00
Jeff Garland c9192d1120 fix unused var warning
[SVN r21617]
2004-01-12 04:09:21 +00:00
Jeff Garland 91a596efa6 merge shadow changes from main branch
[SVN r21606]
2004-01-11 19:33:21 +00:00
John Maddock 494442eb1d merged changes from main branch
[SVN r21574]
2004-01-10 12:13:53 +00:00
Jeff Garland 42163012b3 update version number
[SVN r21484]
2004-01-04 23:04:36 +00:00
nobody 5d7e21180a This commit was manufactured by cvs2svn to create branch 'RC_1_31_0'.
[SVN r21427]
2003-12-30 12:10:04 +00:00
21 changed files with 590 additions and 227 deletions
+19 -3
View File
@@ -17,14 +17,30 @@ CPP_SOURCES =
dll boost_date_time
: ../src/gregorian/$(CPP_SOURCES).cpp
: <sysinclude>$(BOOST_ROOT)
:
<sysinclude>$(BOOST_ROOT)
$(DATE_TIME_PROPERTIES)
<runtime-link>dynamic
<define>BOOST_ALL_DYN_LINK=1
# the common names rule ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
: debug release ;
lib boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
: <sysinclude>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_STATIC_LINK
: debug release <runtime-link>static
:
<sysinclude>$(BOOST_ROOT)
$(DATE_TIME_PROPERTIES)
<define>BOOST_DATE_TIME_STATIC_LINK
# the common names rule ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
:
debug
release
<runtime-link>static
;
install date_time lib
+43 -25
View File
@@ -24,16 +24,22 @@
<H2><a name="overview">Overview</a></H2>
<p>
The library has several functions that require the creation of a library file.
The Jamfile in the build directory will produce a library
(<font class="bold">libboost_date_time</font>) that contains these functions.
The Jamfile in the build directory (BOOST_ROOT/libs/date_time/build) will
produce the <font class="bold">libboost_date_time</font> library
that contains these functions. The library is compiled into both
static and dynamic (dll) forms. Note that the static library is the
prefered form as some compilers have spurious regression test
errors using the dynamic library. See the
<a href="http://boost.sourceforge.net/regression-logs/">regression test logs at sourceforge </a> for more details.
<p>
<H2><a name="options">Compilation Options</a></H2>
<p>
By default the posix_time system uses a 64 bit integer and a 32 bit
integer internally to provide nano-second level resolutions. As
an alternative, a single 64 bit integer can be used to provide a
microsecond level resolution. This alternative implementation
may provide better performance and more compact memory usage
integer internally to provide nano-second level resolutions -- 96
bits for each time value. As an alternative, a single 64 bit integer
can be used to provide a microsecond level resolution. This alternative
implementation may provide better performance and more compact memory usage
for many applications that do not require nano-second resolutions.
<p>
The variable <b>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG</b>, as defined in
@@ -42,30 +48,42 @@ integer implementation simply remove this define from the Jamfile.
<p>
<H2><a name="portability">Compiler/Portability Notes</a></H2>
<p>
The Boost Date-Time library has been built and tested with many compilers.
The Boost Date-Time library has been built and tested with many compilers
on many platforms. In general, the more standard compliant the compiler
and library combination the more likely the library will be fully supported.
However, some compilers and standard libraries have issues. While some
of these issues can be worked around, others are difficult to work
around. The following compilers fully support all aspects of the library:
around. The following compilers <b>fully support</b> all aspects of the library:
<ul>
<li>GCC 3.0.3 on Linux
<li>GCC 3.1 (cygwin)
<li>MSVC 7
<li>GCC 3.x on Linux
<li>GCC 3.1 (cygwin) for Windows
<li>GCC 3.3 on Mac
<li>Borland 5.6.4 for Windows
<li>MSVC 7.1 on Windows
<li>MIPSpro 7.4 on SGI
<li>VisualAge 6.0 on IBM AIX
</ul>
<p>
In particular, a lack of support for standard locales limits the ability
of the library to support iostream based input output. For these
of the library to support iostream based input and output. For these
compilers a set of more limited string based input-output is provided.
In addition, some compilers have regression test failures with the dll form
of the library or other issues that may prevent using some aspects of the
library.
The compilers/standard libraries with this limitation include:
Some compilers/standard libraries with known <b>limitations</b> include:
<p>
<ul>
<li>GCC 2.9x on Linux
<li>Borland 5.1.1 and 5.6
<li>MSVC 6 SP5
<li>Borland 5.1.1 on Windows
<li>Intel 8.00 on Windows
<li>Metrowerks 8.3 on Windows
<li>MSVC 6 SP5 on Windows
<li>MSVC 7 on Windows
</ul>
Other compilers such as Comeau and Metroworks have been tested
successfully with earlier versions of the library.
A great resource for the details on this subject are
the boost <a href="http://boost.sourceforge.net/regression-logs/">regression test logs at sourceforge </a>.
<p>
<H2><a name="directory">Directory Structure</a></H2>
@@ -91,21 +109,21 @@ The directory tree has the following structure:
<H2><a name="required">Required Boost Libraries</a></H2>
<p>
The library depends on
The library depends on the following boost libraries:
<ul>
<li><a href="../../tokenizer/index.html">boost.tokenizer</a>,
<li><a href="../../integer/cstdint.htm">boost.integer(cstdint)</a>,
<li><a href="../../utility/operators.htm">boost.operators</a>, and
<li><a href="../../conversion/lexical_cast.htm">boost::lexical_cast</a>
<li><a href="../../config/config.htm">config</a>
<li><a href="../../integer/cstdint.htm">integer(cstdint)</a>
<li><a href="../../utility/operators.htm">operators</a>
<li><a href="../../conversion/lexical_cast.htm">lexical_cast</a>
<li><a href="../../tokenizer/index.html">tokenizer</a>
</ul>
so at least these libraries need to be installed.
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Sun Jan 19 16:22:27 MST 2003
Last modified: Sun Feb 1 16:30:13 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2004
</small></address>
</body>
</html>
+25 -11
View File
@@ -32,6 +32,12 @@
warning level 4.
</td>
</tr>
<tr class="content">
<td class="nowrap">Bug Fix</td>
<td>Fixed many GCC compiler warnings when compiled with
-Wshadow.
</td>
</tr>
<tr class="content">
<td class="nowrap">Feature</td>
<td>Added prefix decrement operator (--) for date and time iterators.
@@ -43,15 +49,16 @@
</tr>
<tr class="content">
<td class="nowrap">Feature</td>
<td>Special_values functionality added for date_duration,
time_duration and time classes. Code provided by Bart Garst.
<td>Special values functionality (eg: infinities, not_a_date_time)
added for date_duration, time_duration and time classes.
Code provided by Bart Garst.
</td>
</tr>
<tr class="content">
<td class="nowrap">Bug Fix</td>
<td>Fixed time_duration_traits calculation bug which was
causing time duration to be limited to 32bit range even
when 64 bits were available. Thanks to Joe de Guzman
when 64 bits were available. Thanks to Joel de Guzman
for tracking this down.
</td>
</tr>
@@ -73,7 +80,9 @@
</tr>
<tr class="content">
<td class="nowrap">Feature</td>
<td>Added from_time_t function to convert time_t to a ptime.
<td>Added from_time_t function to convert time_t to a ptime. See
<a href="class_ptime.html#constructfromtimet">from_time_t</a>
from more.
</td>
</tr>
<tr class="content">
@@ -94,6 +103,8 @@
seconds(1).total_microseconds() == 1000000<br>
hours(1).total_milliseconds() == 3600*1000 //3600 sec/hour<br>
seconds(1).total_nanoseconds() == 1000000000<br>
See <a href="class_time_duration.html">time duration</a> for more.
</td>
</tr>
<tr class="content">
@@ -118,11 +129,14 @@
multiple formats ("2003-10-31","2003-Oct-31", and
"2003-October-31").
Thus, date d = from_simple_string("2003-Feb-27") is now
allowed. A bad month name string (
from_simple_string("2003-SomeBogusMonthName-27")) will
cause a bad_month exception.
On most compilers the string compare is case
insensitive.
allowed. A bad month name string
(from_simple_string("2003-SomeBogusMonthName-27")) will
cause a bad_month exception. In addition, there are
new convenience functions that handle different orderings of the
year, month, and day. The from_us_date and from_uk_date
<a href="class_date.html#constructfromstring">(reference)</a>
provide parsing for the order month-day-year and day-month-year respectively.
On most compilers the month string compare is case insensitive.
Thanks to Bart Garst for this work.
</td>
</tr>
@@ -221,9 +235,9 @@
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Sun Nov 2 20:31:55 MST 2003
Last modified: Sun Feb 1 09:21:26 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2004
</small></address>
</body>
</html>
+81 -40
View File
@@ -50,36 +50,65 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>date(greg_year year, greg_month month, greg_day day)</td>
<tr><td class="nowrap">date(greg_year year, greg_month month, greg_day day)</td>
<td>Construct from parts of date. <b>Throws</b> bad_year,
bad_day_of_month, or bad_month (derivatives
of std::out_of_range) if
the year, month or day are out of range.
</td>
<td>date d(2002,Jan,10)</td></tr>
<td class="nowrap">date d(2002,Jan,10)</td></tr>
<tr><td>date(date d)</td>
<td>Copy constructor</td>
<td>date d1(d)</td></tr>
<tr><td>date(special_values sv)</td>
<tr><td class="nowrap">date(special_values sv)</td>
<td>Constructor for infinities, not-a-date-time, max_date, and min_date</td>
<td>date d1(neg_infin);<br>date d2(pos_infin);<br>date d3(not_a_date_time);<br>date d4(max_date);<br>date d5(min_date);</td></tr>
<td class="nowrap">date d1(neg_infin);<br>
date d2(pos_infin);<br>
date d3(not_a_date_time);<br>
date d4(max_date);<br>
date d5(min_date);
</td></tr>
</table>
<p>
<h2><a name="constructfromstring">Construction From String</a></h2>
The various delimited string parsers will parse dates with various types of delimiters
such as '-', '/', or spaces. In addition, the delimited parsers accept months as either
a numeric value or as a short or long case-insensitive string. For example, the
from_string function will accept all the following strings for the date Jan 25, 2002.
<ul>
<li>2002-1-25
<li>2002-Jan-25
<li>2002-January-25
<li>2002 January 25
<li>2002 jan 25
<li>2002/1/25
<li>2002/Jan/25
<li>...
</ul>
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>date <font class="func">from_string</font>(const std::string&)</td>
<td>From delimited date string where with order year-month-day eg: 2002-1-25</td>
<td>std::string ds("2002/1/25");<br>
<td>From delimited date string where with order iso standard
ordering: year-month-day (eg: 2002-1-25)</td>
<td>std::string ds("2002/1/25"); //or 2002-Jan-25, etc<br>
date d(from_string(ds))</td></tr>
<tr><td>date <font class="func">from_undelimited_string</font>(const std::string&)</td>
<tr><td class="nowrap">date <font class="func">from_us_string</font>(const std::string&)</td>
<td>A delimited date string where with order month-day-year eg: 1-25-2002</td>
<td class="nowrap">std::string ds("1/25/2002");<br>
date d(from_us_string(ds))</td></tr>
<tr><td class="nowrap">date <font class="func">from_uk_string</font>(const std::string&)</td>
<td>A delimited date string where with order day-month-year eg: 25-1-2002</td>
<td class="nowrap">std::string ds("25/1/2002");<br>
date d(from_us_string(ds))</td></tr>
<tr><td class="nowrap">date <font class="func">from_undelimited_string</font>(const std::string&)</td>
<td>From iso type date string where with order year-month-day eg: 20020125</td>
<td>std::string ds("20020125");<br>
<td class="nowrap">std::string ds("20020125");<br>
date d(from_undelimited_string(ds))</td></tr>
</table>
@@ -93,9 +122,10 @@ or
<tr><td>day_clock::local_day()</td>
<td>Get the local day based on the time zone settings of the computer.</td>
<td>date d(day_clock::local_day())</td></tr>
<tr><td>day_clock::universal_day()</td>
<td>Get the UTC day.</td>
<td>date d(day_clock::universal_day())</td></tr>
<tr><td class="nowrap">day_clock::universal_day()</td>
<td>Get the UTC (Universal Time Coordinated) day based on the time zone settings of
the local computer.</td>
<td class="nowrap">date d(day_clock::universal_day())</td></tr>
</table>
<p>
@@ -106,39 +136,41 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>greg_year <font class="func">year</font>() const</td>
<tr><td class="nowrap">greg_year <font class="func">year</font>() const</td>
<td>Get the year part of the date.</td>
<td>date d(2002,Jan,10); d.year() --> 2002;</td></tr>
<td class="nowrap">date d(2002,Jan,10); d.year() --> 2002;</td></tr>
<tr><td>greg_month <font class="func">month</font>() const</td>
<td>Get the month part of the date.</td>
<td>date d(2002,Jan,10); d.month() --> 1;</td></tr>
<tr><td>greg_day <font class="func">day</font>() const</td>
<td class="nowrap">date d(2002,Jan,10); d.month() --> 1;</td></tr>
<tr><td class="nowrap">greg_day <font class="func">day</font>() const</td>
<td>Get the day part of the date.</td>
<td>date d(2002,Jan,10); d.day() --> 10;</td></tr>
<td class="nowrap">date d(2002,Jan,10); d.day() --> 10;</td></tr>
<tr><td>greg_ymd <font class="func">year_month_day</font>() const</td>
<td>Return a year_month_day struct. More efficient when all 3 parts of the date are needed.</td>
<td>date d(2002,Jan,10);
<br>date::ymd_type ymd = d.year_month_day();
<br>ymd.year --> 2002, ymd.month --> 1, ymd.day --> 10</td></tr>
<tr><td>greg_day_of_week <font class="func">day_of_week</font>() const</td>
<tr><td class="nowrap">greg_day_of_week <font class="func">day_of_week</font>() const</td>
<td>Get the day of the week (eg: Sunday, Monday, etc.</td>
<td>date d(2002,Jan,10); d.day() --> Thursday;</td></tr>
<tr><td>bool <font class="func">is_infinity</font>() const</td>
<td class="nowrap">date d(2002,Jan,10); d.day() --> Thursday;</td></tr>
<tr><td class="nowrap">bool <font class="func">is_infinity</font>() const</td>
<td>Returns true if date is either positive or negative infinity</td>
<td>date d(pos_infin); d.is_infinity() --> true;</td></tr>
<tr><td>bool <font class="func">is_neg_infinity</font>() const</td>
<td class="nowrap">date d(pos_infin); d.is_infinity() --> true;</td></tr>
<tr><td class="nowrap">bool <font class="func">is_neg_infinity</font>() const</td>
<td>Returns true if date is negative infinity</td>
<td>date d(neg_infin); d.is_neg_infinity() --> true;</td></tr>
<tr><td>bool <font class="func">is_pos_infinity</font>() const</td>
<td class="nowrap">date d(neg_infin); d.is_neg_infinity() --> true;</td></tr>
<tr><td class="nowrap">bool <font class="func">is_pos_infinity</font>() const</td>
<td>Returns true if date is positive infinity</td>
<td>date d(neg_infin); d.is_pos_infinity() --> true;</td></tr>
<tr><td>bool <font class="func">is_not_a_date</font>() const</td>
<td class="nowrap">date d(neg_infin); d.is_pos_infinity() --> true;</td></tr>
<tr><td class="nowrap">bool <font class="func">is_not_a_date</font>() const</td>
<td>Returns true if value is not a date</td>
<td>date d(not_a_date_time); d.is_not_a_date() --> true;</td></tr>
<tr><td>long <font class="func">modjulian_day</font>() const</td>
<td class="nowrap">date d(not_a_date_time); <br>
d.is_not_a_date() --> true;
</td></tr>
<tr><td class="nowrap">long <font class="func">modjulian_day</font>() const</td>
<td>Returns the modified julian day for the date.</td>
<td></td></tr>
<tr><td>long <font class="func">julian_day</font>() const</td>
<tr><td class="nowrap">long <font class="func">julian_day</font>() const</td>
<td>Returns the julian day for the date.</td>
<td></td></tr>
<tr><td>int <font class="func">week_number</font>() const</td>
@@ -150,16 +182,21 @@ or
<p>
<h2><a name="conversiontostring">Conversion To String</a></h2>
These convenience functions provide simple ways to converts a date into
a string. The functions are in large part here to support legacy compilers
that do not correctly support locales. See operator<< below for a normal
way to convert a date into a string.
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>std::string <font class="func">to_simple_string</font>(date d)</td>
<tr><td class="nowrap">std::string <font class="func">to_simple_string</font>(date d)</td>
<td>To YYYY-mmm-DD string where mmm 3 char month name.</td>
<td>2002-Jan-01</td></tr>
<tr><td>std::string <font class="func">to_iso_string</font>(date d)</td>
<tr><td class="nowrap">std::string <font class="func">to_iso_string</font>(date d)</td>
<td>To YYYYMMDD where all components are integers.</td>
<td>20020131</td></tr>
<tr><td>std::string <font class="func">to_iso_extended_string</font>(date d)</td>
<tr><td class="nowrap">std::string <font class="func">to_iso_extended_string</font>(date d)</td>
<td>To YYYY-MM-DD where all components are integers.</td>
<td>2002-01-31</td></tr>
@@ -174,35 +211,39 @@ or
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>operator&lt;&lt;</td>
<td>Stream output operator</td>
<td>Stream output operator. Format of the output is subject to the current
localization settings. See <a href="class_greg_base_facet.html">I/O localization</a>
for more.
</td>
<td>date d(2002,Jan,1)<br>
std::cout &lt;&lt; d &lt;&lt; std::endl;</td></tr>
<tr><td>operator==, operator!=,<br> operator&gt;, operator&lt;
<tr><td class="nowrap">operator==, operator!=,<br> operator&gt;, operator&lt;
<br> operator&gt;=, operator&lt;=</td>
<td>A full complement of comparison operators</td>
<td>d1 == d2, etc</td></tr>
<tr><td>date operator+(date_duration) const</td>
<tr><td class="nowrap">date operator+(date_duration) const</td>
<td>Return a date adding a day offset</td>
<td>date d(2002,Jan,1);
<br>date_duration dd(1);
<br>date d2 = d + dd;</td></tr>
<tr><td>date operator-(date_duration) const</td>
<tr><td class="nowrap">date operator-(date_duration) const</td>
<td>Return a date by adding a day offset </td>
<td>date d(2002,Jan,1);
<br>date_duration dd(1);
<br>date d2 = d - dd;</td></tr>
<tr><td>date_duration operator-(date) const</td>
<tr><td class="nowrap">date_duration operator-(date) const</td>
<td>Return a date duration by subtracting two dates</td>
<td>date d1(2002,Jan,1);
<br>date d2(2002,Jan,2);
<br>date_duration dd = d2-d1;</td></tr>
<td class="nowrap">date d1(2002,Jan,1); <br>
date d2(2002,Jan,2); <br>
date_duration dd = d2-d1;
</td></tr>
</table>
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Wed Dec 24 18:51:40 MST 2003
Last modified: Mon Jan 19 21:34:44 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
</small></address>
+18 -2
View File
@@ -27,7 +27,11 @@
<h2><a name="intro">Introduction</a></h2>
<p>
The class boost::gregorian::date_duration is a simple day count used for arithmetic with <a href="class_date.html">gregorian::date</a>. A duration can be either positive or negative.
The class boost::gregorian::date_duration is a simple day count used for arithmetic
with <a href="class_date.html">gregorian::date</a>. A duration can be either
positive or negative. In addition, date_durations can take on special values such
as not_a_date_time. More information on how these special values impact calculation
can be found in <a href="Calculations.html">Calculations</a>.
<p>
<p>
@@ -48,6 +52,13 @@ or
<tr><td>date_duration(long)</td>
<td>Create a duration count.</td>
<td>date_duration dd(3); //3 days</td></tr>
<tr><td>date_duration(const date_duration& dd)</td>
<td>Copy constructor.</td>
<td></td></tr>
<tr><td>date_duration(special_values)</td>
<td>Create a duration with a special value such as neg_infin,
pos_infin or not_a_date_time</td>
<td>date_duration dd(note_a_date_time); //invalid value</td></tr>
</table>
<p>
@@ -93,6 +104,11 @@ or
<td>date_duration dd1(3);
<br>date_duration dd2(5);
<br>date_duration dd3 = dd1 - dd2;</td></tr>
<tr><td>date_duration operator-() const</td>
<td>Invert sign</td>
<td>date_duration dd1(3);
<br>-dd1; // dd1 == -3 days
</td></tr>
</table>
@@ -102,7 +118,7 @@ or
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Wed Aug 21 15:12:43 MST 2002
Last modified: Sun Jan 18 15:15:35 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
</small></address>
+2 -2
View File
@@ -151,7 +151,7 @@ or
</td>
<td class="nowrap">date_period dp1(date(2002,Jan,1), date(2002,Jan,5));<br>
date_period dp2(date(2002,Jan,9), date(2002,Jan,31));<br>
dp2.hull(dp1) --> 2002-Jan-01/2002-Jan-31</td></tr>
dp2.span(dp1) --> 2002-Jan-01/2002-Jan-31</td></tr>
<tr><td>date_period <font class="func">shift</font>(date_duration)</td>
<td>Add duration to both start and end.</td>
<td class="nowrap">date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
@@ -198,7 +198,7 @@ or
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Tue Aug 19 06:46:09 MST 2003
Last modified: Sun Jan 18 14:39:36 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2003
</small></address>
+96 -24
View File
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Date I/O Documentation</title>
<title>Date I/O Localization</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
@@ -8,7 +8,7 @@
<a href="../../../index.htm">
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
</a>
<h1>Date Input/Output</h1>
<h1>Date I/O Localization</h1>
<p>&nbsp;</p>
<hr>
<a href="index.html">Overall Index</a> --
@@ -23,7 +23,87 @@
The library provides for localized stream-based I/O of dates and times.
Note that this support is not supported for all compilers. See the
<a href="BuildInfo.html">build information</a> page for details.
<p>
To provide for date output (and eventually input) the library uses a specialized
facet class that provides the month name strings (both short and long -- eg: Jan, January),
order of the date output (year-month-day, day-month-year, etc), and the delimeters
between various parts of the date. To localize the date the process entails constructing
the facet with the desired parameters, calling imbue on the stream, and then streaming
the date.
<p>
By default, the date operator &lt;&lt; uses the following default strings:
<div class="fragment"><pre>
us_short_month_names={"Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec", "NAD"};
us_long_month_names={"January","February","March","April","May","June","July",
"August","September","October","November","December","Not-A-Date"};
us_special_value_names={"Not-A-Date","-infinity", "+infinity"};
us_long_weekday_names={"Sunday", "Monday", "Tuesday","Wenesday", "Thursday", "Friday", "Saturday"};
us_short_weekday_names={"Sun", "Mon", "Tue","Wed", "Thu", "Fri", "Sat"};
</pre></div>
<p>
The following example shows how to output dates using German names first with short month names
and then with long month names.
<div class="fragment"><pre>
<font class="keyword">using namespace</font> boost::gregorian;
typedef boost::date_time::all_date_names_put&lt;greg_facet_config&gt; date_facet;
const char* const de_short_month_names[]={"Jan","Feb","Mar","Apr","Mai",
"Jun","Jul","Aug","Sep","Okt",
"Nov","Dez", "NAM"};
const char* const de_long_month_names[]={"Januar","Februar","Marz","April",
"Mai","Juni","Juli","August","September",
"Oktober","November","Dezember","NichtDerMonat"};
const char* const de_special_value_names[]={"NichtDatumzeit",
"-unbegrenztheit",
"+unbegrenztheit"};
const char* const de_long_weekday_names[]={"Sonntag", "Montag", "Dienstag",
"Mittwoch", "Donnerstag", "Freitag",
"Samstag"};
const char* const de_short_weekday_names[]={"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"};
std::locale default_locale;
<font class="comment">//Create the date facet based on the default locale</font>
std::locale german_dates(default_locale,
new date_facet(de_short_month_names,
de_long_month_names,
de_special_value_names,
de_short_weekday_names,
de_long_weekday_names,
'.', <font class="comment">//separate parts using a '.'</font>
boost::date_time::ymd_order_ymd,
boost::date_time::month_as_short_string));
<font class="comment">// Imbue the stream with the locale</font>
std::cout.imbue(german_dates);
date d1(2002, Oct, 1);
<font class="comment">// output the date in German using short month names</font>
std::cout &lt;&lt; d1 &lt;&lt; std::endl; <font class="comment">//01.Okt.2002</font>
std::locale german_dates2(default_locale,
new date_facet(de_short_month_names,
de_long_month_names,
de_special_value_names,
de_short_weekday_names,
de_long_weekday_names,
'-', <font class="comment">//separate parts using a '-'</font>
boost::date_time::ymd_order_iso,
boost::date_time::month_as_long_string));
std::cout.imbue(german_dates2); <font class="comment">//use long month names</font>
std::cout &lt;&lt; d1 &lt;&lt; std::endl; <font class="comment">//2002-Oktober-01</font>
</pre></div>
<p>
<a name="classoverview"><h2>Class Overview</h2></a>
<p>
@@ -31,34 +111,26 @@ Note that this support is not supported for all compilers. See the
<tr><td><b>Class</b></td>
<td><b>Construction Parameters</b></td>
<td><b>Description</b></td></tr>
<tr><td>date_iterator</td>
<td></td>
<td>Common base class for all day level iterators.</td></tr>
<tr><td>day_iterator</td>
<td>date start_date, int day_count=1</td>
<td>Iterate day_count days at a time.</td></tr>
<tr><td>week_iterator</td>
<td>date start_date, int week_offset=1</td>
<td>Iterate week_offset weeks at a time.</td></tr>
<tr><td>month_iterator</td>
<td>date start_date, int month_offset=1</td>
<td>Iterate month_offset months. There are special rules for
handling the end of the month. These are: if start date is last
day of the month, always adjust to last day of the month.
if date is beyond the end of the month (eg: jan 31 + 1 month)
adjust back to end of month.
</td></tr>
<tr><td>year_iterator</td>
<td>date start_date, int year_offset=1</td>
<td>Iterate year_offset years</td></tr>
<tr><td>date_facet</td>
<td>const char* const month_short_names[]<br>
const char* const month_long_names[]<br>
const char* const special_value_names[]<br>
const char* const weekday_short_names[]<br>
const char* const weekday_long_names[]<br>
char separator_char = '-'<br>
ymd_order_spec order_spec = ymd_order_iso<br>
month_format_spec month_format = month_as_short_string <br>
</td>
<td>Constructor for date facet</td></tr>
</table>
<hr><address><small>
<!-- hhmts start -->
Last modified: Thu Sep 5 07:26:05 MST 2002
Last modified: Sun Feb 1 09:18:06 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2004
</small></address>
</body>
+49 -35
View File
@@ -57,14 +57,20 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>ptime(date,time_duration)</td>
<tr><td class="nowrap">ptime(date,time_duration)</td>
<td>Construct from a date and offset
</td>
<td>ptime t1(date(2002,Jan,10), time_duration(1,2,3));<br>
<td class="nowrap">ptime t1(date(2002,Jan,10), time_duration(1,2,3));<br>
ptime t2(date(2002,Jan,10), hours(1)+nanosec(5));</td></tr>
<tr><td>ptime(ptime)</td>
<tr><td class="nowrap">ptime(ptime)</td>
<td>Copy constructor</td>
<td>ptime t3(t1)</td></tr>
<td class="nowrap">ptime t3(t1)</td></tr>
<tr><td class="nowrap">ptime(special_values sv)</td>
<td>Constructor for infinities, not-a-date-time</td>
<td class="nowrap">ptime t1(neg_infin);<br>
ptime t2(pos_infin);<br>
ptime t3(not_a_date_time);<br>
</td></tr>
</table>
@@ -73,14 +79,14 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>ptime <font class="func">time_from_string</font>(const std::string&)</td>
<tr><td class="nowrap">ptime <font class="func">time_from_string</font>(const std::string&)</td>
<td>From delimited string.</td>
<td>std::string ts("2002-01-20 23:59:59.000");
<td class="nowrap">std::string ts("2002-01-20 23:59:59.000");
<br>
ptime t(time_from_string(ts))</td></tr>
<tr><td>ptime <font class="func">from_iso_string</font>(const std::string&)</td>
<tr><td class="nowrap">ptime <font class="func">from_iso_string</font>(const std::string&)</td>
<td>From non delimited iso form string.</td>
<td>std::string ts("20020131T235959");
<td class="nowrap">std::string ts("20020131T235959");
<br>
ptime t(from_iso_string(ts))</td></tr>
</table>
@@ -91,12 +97,12 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>static ptime second_clock::local_time();</td>
<tr><td class="nowrap">static ptime second_clock::local_time();</td>
<td>Get the local time, second level resolution, based on the time zone settings of the computer.</td>
<td>ptime t(second_clock::local_time())</td></tr>
<tr><td>static ptime second_clock::universal_time()</td>
<td class="nowrap">ptime t(second_clock::local_time())</td></tr>
<tr><td class="nowrap">static ptime second_clock::universal_time()</td>
<td>Get the UTC time.</td>
<td>ptime t(second_clock::universal_day())</td></tr>
<td class="nowrap">ptime t(second_clock::universal_day())</td></tr>
</table>
<p>
@@ -118,14 +124,14 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>date <font class="func">date</font>() const</td>
<tr><td class="nowrap">date <font class="func">date</font>() const</td>
<td>Get the date part of a time.</td>
<td>date d(2002,Jan,10);<br>
<td class="nowrap">date d(2002,Jan,10);<br>
ptime t(d, hour(1));<br>
t.date() --> 2002-Jan-10;</td></tr>
<tr><td>time_duration <font class="func">time_of_day</font>() const</td>
<tr><td class="nowrap">time_duration <font class="func">time_of_day</font>() const</td>
<td>Get the time offset in the day.</td>
<td>date d(2002,Jan,10);<br>
<td class="nowrap">date d(2002,Jan,10);<br>
ptime t(d, hour(1));<br>
t.time_of_day() --> 01:00:00;</td></tr>
</table>
@@ -136,15 +142,15 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>std::string <font class="func">to_simple_string</font>(ptime)</td>
<tr><td class="nowrap">std::string <font class="func">to_simple_string</font>(ptime)</td>
<td>To YYYY-mmm-DD HH:MM:SS.fffffffff string where mmm 3 char month name. Fractional seconds only included if non-zero.</td>
<td>2002-Jan-01 10:00:01.123456789</td></tr>
<tr><td>std::string <font class="func">to_iso_string</font>(ptime)</td>
<td class="nowrap">2002-Jan-01 10:00:01.123456789</td></tr>
<tr><td class="nowrap">std::string <font class="func">to_iso_string</font>(ptime)</td>
<td>Convert to form YYYYMMDDTHHMMSS,fffffffff where T is the date-time separator</td>
<td>20020131T100001,123456789</td></tr>
<tr><td>std::string <font class="func">to_iso_extended_string</font>(ptime)</td>
<td class="nowrap">20020131T100001,123456789</td></tr>
<tr><td class="nowrap">std::string <font class="func">to_iso_extended_string</font>(ptime)</td>
<td>Convert to form YYYY-MM-DDTHH:MM:SS,fffffffff where T is the date-time separator</td>
<td>2002-01-31T10:00:01,123456789</td></tr>
<td class="nowrap">2002-01-31T10:00:01,123456789</td></tr>
</table>
<p>
@@ -156,35 +162,43 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>operator==, operator!=,<br> operator&gt;, operator&lt;
<tr><td><font class="func">operator&lt;&lt;</font></td>
<td>Stream output operator. Format of the date output is subject to the current
localization settings. See <a href="class_greg_base_facet.html">I/O localization</a>
for more.
</td>
<td class="nowrap">date d(2002,Jan,1)<br>
ptime t(d, hours(3)+minutes(2)+milliseconds(1));<br>
std::cout &lt;&lt; t &lt;&lt; std::endl;//2002-Jan-01 03:02:00.001</td></tr>
<tr><td class="nowrap">operator==, operator!=,<br> operator&gt;, operator&lt;
<br> operator&gt;=, operator&lt;=</td>
<td>A full complement of comparison operators</td>
<td>t1 == t2, etc</td></tr>
<tr><td>ptime <font class="func">operator+</font>(date_duration) const</td>
<td class="nowrap">t1 == t2, etc</td></tr>
<tr><td class="nowrap">ptime <font class="func">operator+</font>(date_duration) const</td>
<td>Return a ptime adding a day offset</td>
<td>date d(2002,Jan,1);<br>
<td class="nowrap">date d(2002,Jan,1);<br>
ptime t(d,minutes(5));<br>
date_duration dd(1); <br>
ptime t2 = t + dd;</td></tr>
<tr><td>ptime <font class="func">operator-</font>(date_duration) const</td>
<tr><td class="nowrap">ptime <font class="func">operator-</font>(date_duration) const</td>
<td>Return a ptime subtracting a day offset</td>
<td>date d(2002,Jan,1);<br>
<td class="nowrap">date d(2002,Jan,1);<br>
ptime t(d,minutes(5));<br>
date_duration dd(1); <br>
ptime t2 = t - dd;</td></tr>
<tr><td>ptime <font class="func">operator+</font>(time_duration) const</td>
<tr><td class="nowrap">ptime <font class="func">operator+</font>(time_duration) const</td>
<td>Return a ptime adding a time duration</td>
<td>date d(2002,Jan,1);<br>
<td class="nowrap">date d(2002,Jan,1);<br>
ptime t(d,minutes(5));<br>
ptime t2 = t + hours(1) + minutes(2);</td></tr>
<tr><td>ptime <font class="func">operator-</font>(time_duration) const</td>
<tr><td class="nowrap">ptime <font class="func">operator-</font>(time_duration) const</td>
<td>Return a ptime subtracting a time duration</td>
<td>date d(2002,Jan,1);<br>
<td class="nowrap">date d(2002,Jan,1);<br>
ptime t(d,minutes(5));<br>
ptime t2 = t - minutes(2);</td></tr>
<tr><td>time_duration <font class="func">operator-</font>(ptime) const</td>
<tr><td class="nowrap">time_duration <font class="func">operator-</font>(ptime) const</td>
<td>Take the difference between two times.</td>
<td>date d(2002,Jan,1);<br>
<td class="nowrap">date d(2002,Jan,1);<br>
ptime t1(d,minutes(5));<br>
ptime t2(d,seconds(5));<br>
time_duration t3 = t2 - t1;//negative result</td></tr>
@@ -196,7 +210,7 @@ or
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Sat Aug 9 17:49:45 MST 2003
Last modified: Mon Jan 19 21:49:15 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
</small></address>
+75 -35
View File
@@ -88,32 +88,35 @@ or
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>time_duration(hours,minutes,seconds,fractional_seconds)</td>
<td>Construct ad duration from the counts</td>
<td>Construct a duration from the counts</td>
<td>time_duration td(1,2,3,9); //1 hr 2 min 3 sec 9 nanoseconds</td></tr>
<tr><td>time_duration(special_values)</td>
<td>Construct a time duration with a special value such as not_a_date_time, pos_infin, or neg_infin.</td>
<td>time_duration td(not_a_date_time); //invalid value</td></tr>
</table>
<p>
<h2><a name="countbasedconstruct">Construction By Count</a></h2>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>hours(long)</td>
<tr><td class="nowrap">hours(long)</td>
<td>Number of hours</td>
<td>time_duration td = hours(3);</td></tr>
<td class="nowrap">time_duration td = hours(3);</td></tr>
<tr><td>minutes(long)</td>
<td>Number of minutes</td>
<td>time_duration td = minutes(3);</td></tr>
<tr><td>seconds(long)</td>
<td>Number of seconds</td>
<td>time_duration td = seconds(3);</td></tr>
<tr><td>millisec(long)</td>
<tr><td>milliseconds(long)</td>
<td>Number of milliseconds.</td>
<td>time_duration td = millisec(3);</td></tr>
<tr><td>microsec(long)</td>
<td>time_duration td = milliseconds(3);</td></tr>
<tr><td>microseconds(long)</td>
<td>Number of microseconds.</td>
<td>time_duration td = microsec(3);</td></tr>
<tr><td>nanosec(long)</td>
<td>time_duration td = microseconds(3);</td></tr>
<tr><td class="nowrap">nanoseconds(long)</td>
<td>Number of nanoseconds.</td>
<td>time_duration td = nanosec(3);</td></tr>
<td class="nowrap">time_duration td = nanoseconds(3);</td></tr>
</table>
@@ -137,38 +140,71 @@ or
<p>
<table border=1 cellspacing=3 cellpadding=3>
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
<tr><td>long <font class="func">hours</font>() const</td>
<tr><td class="nowrap">long <font class="func">hours</font>() const</td>
<td>Get the number of normalized hours.</td>
<td>time_duration td(1,2,3); td.hours() --> 1</td></tr>
<tr><td>long <font class="func">minutes</font>() const</td>
<tr><td class="nowrap">long <font class="func">minutes</font>() const</td>
<td>Get the number of minutes normalized (0..59).</td>
<td>time_duration td(1,2,3); td.minutes() --> 2</td></tr>
<tr><td>long <font class="func">seconds</font>() const</td>
<tr><td class="nowrap">long <font class="func">seconds</font>() const</td>
<td>Get the normalized number of second (0..59).</td>
<td>time_duration td(1,2,3); td.seconds() --> 3</td></tr>
<tr><td>long <font class="func">total_seconds</font>() const</td>
<tr><td class="nowrap">bool <font class="func">is_special</font>() const</td>
<td>Returns true if the value of the duration is a special value, otherwise false.</td>
<td>time_duration td(neg_infin); <br>
td.is_special() --> true</td></tr>
<tr><td class="nowrap">bool <font class="func">is_neg_infinity</font>() const</td>
<td>Returns true if the value of the duration is negative infinity, otherwise false.</td>
<td>time_duration td(neg_inifin); <br>
td.is_neg_infinity() --> true</td></tr>
<tr><td class="nowrap">bool <font class="func">is_pos_infinity</font>() const</td>
<td>Returns true if the value of the duration is positive infinity, otherwise false.</td>
<td>hours h(5); <br>
h.is_pos_infinity() --> false</td></tr>
<tr><td class="nowrap">long <font class="func">total_seconds</font>() const</td>
<td>Get the total number of seconds truncating
any fractional seconds.</td>
<td>time_duration td(1,2,3,10); <br>
<td class="nowrap">time_duration td(1,2,3,10); <br>
td.total_seconds() --> (1*3600) + (2*60) + 3 == 3723</td></tr>
<tr><td>long <font class="func">fractional_seconds</font>() const</td>
<td>Get the number of fractional seconds.</td>
<td>time_duration td(1,2,3, 1000); td.fractional_seconds() --> 1000</td></tr>
<tr><td>bool <font class="func">is_negative</font>() const</td>
<tr><td class="nowrap">long <font class="func">total_microseconds</font>() const</td>
<td>Return the total number of microseconds in the duration
truncating any fractional lower resolution (eg: nano
second counts).
</td>
<td>seconds(1).total_microseconds() == 1000000</td></tr>
<tr><td class="nowrap">long <font class="func">total_milliseconds</font>() const</td>
<td>Return the total number of milliseconds in the duration
truncating any fractional lower resolution (eg: micro or nano
second counts).
</td>
<td>seconds(1).total_milliseconds() == 1000</td></tr>
<tr><td class="nowrap">long <font class="func">total_nanoseconds</font>() const</td>
<td>Return the total number of nanoseconds in the duration.
</td>
<td>seconds(1).total_nanoseconds() == 1000000000</td></tr>
<tr><td class="nowrap">long <font class="func">fractional_seconds</font>() const</td>
<td>Get the fractional seconds count. Note that the results of this
method vary based on the resolution of template instantiation
for the time duration (Normally either a nano-second or millisecond
count).
</td>
<td class="nowrap">time_duration td(1,2,3, 1000); <br>
td.fractional_seconds() --> 1000</td></tr>
<tr><td class="nowrap">bool <font class="func">is_negative</font>() const</td>
<td>True if duration is negative.</td>
<td>time_duration td(-1,0,0); td.is_negative() --> true</td></tr>
<tr><td>time_duration <font class="func">invert_sign</font>() const</td>
<td>Generate a new duration with the sign inverted/</td>
<td>time_duration td(-1,0,0); td.invert_sign() --> 01:00:00</td></tr>
<tr><td>static boost::date_time::time_resolutions <font class="func">resolution</font>()</td>
<td>Describes the resolution capability of the time_duration class.</td>
<td>time_duration::resolution() --> nano</td></tr>
<tr><td>boost::int64_t <font class="func">ticks</font>()</td>
<td>Return the raw count of the duration type.</td>
<td>time_duration td(0,0,0, 1000); td.ticks() --> 1000</td></tr>
<tr><td>static time_duration <font class="func">unit</font>()</td>
<td class="nowrap">time_duration td(0,0,0, 1000); td.ticks() --> 1000</td></tr>
<tr><td class="nowrap">static boost::int64_t <font class="func">ticks_per_second</font>()</td>
<td>Return the number of ticks held internally to represent a second, which is
driven by the resolution settings. For nano second resolution the value
1000000000.
</td>
<td class="nowrap">time_duration::ticks_per_second() == 1000000000 //nano second resolution</td></tr>
<tr><td class="nowrap">static time_duration <font class="func">unit</font>()</td>
<td>Return smallest possible unit of duration type (1 nanosecond).</td>
<td>time_duration::unit() --> time_duration(0,0,0,1)</td></tr>
<td class="nowrap">time_duration::unit() --> time_duration(0,0,0,1)</td></tr>
</table>
@@ -200,20 +236,24 @@ or
operator&gt;, operator&lt; <br>
operator&gt;=, operator&lt;=</td>
<td>A full complement of comparison operators</td>
<td>dd1 == dd2, etc</td></tr>
<tr><td>time_duration operator+(time_duration) const</td>
<td>td1 == td2, etc</td></tr>
<tr><td class="nowrap">time_duration operator+(time_duration) const</td>
<td>Add durations.</td>
<td>time_duration td1(hours(1)+minutes(2));
<td class="nowrap">time_duration td1(hours(1)+minutes(2));
<br>time_duration td2(seconds(10));
<br>time_duration td3 = td1 + td2;</td></tr>
<tr><td>time_duration operator-(time_duration) const</td>
<tr><td class="nowrap">time_duration operator-(time_duration) const</td>
<td>Subtract durations.</td>
<td>time_duration td1(hours(1)+nanosec(2)); <br>
<td class="nowrap">time_duration td1(hours(1)+nanosec(2)); <br>
time_duration td2 = td1 - minutes(1);</td></tr>
<tr><td>time_duration operator/(int) const</td>
<tr><td>time_duration operator-() const</td>
<td>Invert sign.</td>
<td>time_duration td1(hours(1)); <br>
-td1; //equal -1 hour</td></tr>
<tr><td class="nowrap">time_duration operator/(int) const</td>
<td>Divide the length of a duration by an integer value. Discards
any remainder.</td>
<td>hours(3)/2 == time_duration(1,30,0);
<td class="nowrap">hours(3)/2 == time_duration(1,30,0);<br>
nanosec(3)/2 == nanosec(1)</td></tr>
<tr><td>time_duration operator*(int) const</td>
<td>Multiply the length of a duration by an integer value. </td>
@@ -227,7 +267,7 @@ or
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Sun Aug 10 16:17:58 MST 2003
Last modified: Mon Jan 19 19:44:14 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2003
</small></address>
+5 -4
View File
@@ -27,12 +27,13 @@
<p>
Date iterators provide a standard mechanism for iteration through dates.
Date iterators are a model of
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
Date iterators are are similar to <a href="http://www.sgi.com/tech/stl/BidirectionalIterator.html">Bidirectional Iterators</a>
and can be used to populate collections with dates and other date generation
tasks. For example, the <a href="exp-print_month.html">print month</a> example iterates through all the days in a month and prints them.
<p>
All of the iterators here derive from boost::gregorian::date_iterator.
All of the iterators here derive from boost::gregorian::date_iterator and provide a
various comparison operations against dates including equal, not equal, less, lees equal,
greater, and greater equal.
<p>
<h2><a name="header">Header</a></h2>
@@ -73,7 +74,7 @@ or
<hr><address><small>
<!-- hhmts start -->
Last modified: Thu Sep 5 06:06:41 MST 2002
Last modified: Sun Jan 18 14:32:56 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
</small></address>
+16 -6
View File
@@ -11,7 +11,7 @@
<h1>Boost Date-Time Library Documentation</h1>
<p>
<h3 align="center">Version 1.02-prerelease</h3>
<h3 align="center">Version 1.02</h3>
<hr>
<h2><a name="contents">Contents</a></h2>
@@ -30,7 +30,7 @@
<a href="BuildInfo.html">Build-Compiler Information</a> --
<a href="Changes.html">Change History</a> --
<a href="#test">Tests</a> --
<a href="license.html">License</a> --
<a href="#license">License</a> --
<a href="BasicTerms.html">Basic Terminology Reference</a> --
<a href="References.html">References</a>
@@ -193,7 +193,10 @@ various compilers. For initial development of concepts and
design Corwin Joy and Michael Kenniston deserve special thanks.
Also extra thanks to Michael for writing up the theory and tradeoffs
part of the documentation. Dave Zumbro for initial inspiration
and sage thoughts. Many thanks
and sage thoughts. For boost release 1.31 Bart Garst has done
most of the actual programming work -- this is a large number of
bug fixes and extensions!
<p>Many thanks
to boost reviewers and users including:
William Seymour, Kjell Elster, Beman Dawes, Gary Powell,
Andrew Maclean, William Kempf, Peter Dimov, Chris Little,
@@ -209,14 +212,21 @@ The design of the library is currently being evolved using Wiki and email discu
<p>
<ul>
<li><a href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?GDTL">Boost Wiki GDTL Start Page</a>
<li><a href="http://www.crystalclearsoftware.com/libraries/gdtl/gdtl_ref_guide/index.html">Full Doxygen Reference Manual</a></ul>
<li><a href="http://www.crystalclearsoftware.com/libraries/gdtl/gdtl_ref_guide/index.html">Full Doxygen Reference Manual (@ CrystalClear Software)</a></ul>
<p>
<h2><a name="license">License</a></h2>
<p>
In short, open for any use without warranty. For details see the Boost software license at <a href="http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt</a>
<p>
<hr>
<address><small>
<!-- hhmts start -->
Last modified: Sat Aug 9 11:03:24 MST 2003
Last modified: Sun Feb 1 15:43:11 MST 2004
<!-- hhmts end -->
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2002
by <a href="mailto:jeff&#64;crystalclearsoftware.com">Jeff Garland</a> &copy; 2000-2004
</small></address>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
// This example displays the amount of time until new year's in days
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
using namespace boost::gregorian;
date::ymd_type today = day_clock::local_day_ymd();
date new_years_day(today.year + 1,1,1);
date_duration dd = new_years_day - date(today);
std::cout << "Days till new year: " << dd.days() << std::endl;
return 0;
};
+37
View File
@@ -0,0 +1,37 @@
// Simple program that uses the gregorian calendar to find the last
// day of the month.
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
std::cout << " Enter Year(ex: 2002): ";
int year, month;
std::cin >> year;
std::cout << " Enter Month(1..12): ";
std::cin >> month;
try {
int day = boost::gregorian::gregorian_calendar::end_of_month_day(year,month);
boost::gregorian::date endOfMonth(year,month,day);
std::cout << boost::gregorian::to_simple_string(endOfMonth) << std::endl;
//Iterate thru by months --
boost::gregorian::month_iterator mitr(endOfMonth,1);
boost::gregorian::date startOfNextYear(year+1,1,1);
//loop thru the days and print each one
while (mitr < startOfNextYear){
std::cout << boost::gregorian::to_simple_string(*mitr) << std::endl;
++mitr;
}
}
catch(...) {
std::cout << "Invalid Date Entered" << std::endl;
}
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
// Simple program that uses the gregorian calendar to find the last
// day of the month.
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
using namespace boost::gregorian;
typedef boost::date_time::month_functor<date> add_month;
date d = day_clock::local_day();
add_month mf(1);
date d2 = d + mf.get_offset(d);
std::cout << to_simple_string(d2) << std::endl;
return 0;
}
+37 -16
View File
@@ -61,24 +61,45 @@ namespace std {
*
*/
#if defined(_MSC_VER) && defined(_DLL)
# define BOOST_DATE_TIME_HAS_DLL_RUNTIME
#endif
// BOOST_DATE_TIME_STATIC_LINK is defined in libs/date_time/build/Jamfile
#if (defined(BOOST_DATE_TIME_HAS_DLL_RUNTIME) && \
!defined(BOOST_DATE_TIME_STATIC_LINK))
# if defined(BOOST_DATE_TIME_SOURCE)
# define BOOST_DATE_TIME_DECL __declspec(dllexport)
# define BOOST_DATE_TIME_BUILD_DLL
# else
# define BOOST_DATE_TIME_DECL __declspec(dllimport)
# endif
#endif
#ifdef BOOST_HAS_DECLSPEC // defined in config system
// we need to import/export our code only if the user has specifically
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
// libraries to be dynamically linked, or BOOST_DATE_TIME_DYN_LINK
// if they want just this one to be dynamically liked:
# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
// export if this is our own source, otherwise import:
# ifdef BOOST_DATE_TIME_SOURCE
# define BOOST_DATE_TIME_DECL __declspec(dllexport)
# else
# define BOOST_DATE_TIME_DECL __declspec(dllimport)
# endif // BOOST_DATE_TIME_SOURCE
# endif // DYN_LINK
#endif // BOOST_HAS_DECLSPEC
//
// if BOOST_WHATEVER_DECL isn't defined yet define it now:
#ifndef BOOST_DATE_TIME_DECL
# define BOOST_DATE_TIME_DECL
# define BOOST_DATE_TIME_DECL
#endif
//
// Automatically link to the correct build variant where possible.
//
#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
//
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_date_time
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
# define BOOST_DYN_LINK
#endif
//
// And include the header that does the work:
//
#include <boost/config/auto_link.hpp>
#endif // auto-linking disabled
#endif
+2 -2
View File
@@ -67,8 +67,8 @@ namespace date_time {
typedef typename calendar::date_rep_type date_rep_type;
typedef typename calendar::date_int_type date_int_type;
typedef typename calendar::day_of_week_type day_of_week_type;
date(year_type year, month_type month, day_type day)
: days_(calendar::day_number(ymd_type(year, month, day)))
date(year_type y, month_type m, day_type d)
: days_(calendar::day_number(ymd_type(y, m, d)))
{}
date(const ymd_type& ymd)
: days_(calendar::day_number(ymd))
@@ -45,10 +45,10 @@ namespace gregorian {
typedef gregorian_calendar::date_int_type date_int_type;
typedef date_duration duration_type;
//! Main constructor with year, month, day
date(year_type year, month_type month, day_type day)
: date_time::date<date, gregorian_calendar, date_duration>(year, month, day)
date(year_type y, month_type m, day_type d)
: date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
{
if (gregorian_calendar::end_of_month_day(year, month) < day) {
if (gregorian_calendar::end_of_month_day(y, m) < d) {
throw bad_day_of_month(std::string("Day of month is not valid for year"));
}
}
+10 -10
View File
@@ -411,22 +411,22 @@ private:
//! Assumes at least 'this' or 'rhs' is a special value
int_adapter mult_div_specials(const int_adapter& rhs)const
{
int min;
int min_value;
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(is_signed) {
min = 0;
min_value = 0;
}
else {
min = 1;// there is no zero with unsigned
min_value = 1;// there is no zero with unsigned
}
if(this->is_nan() || rhs.is_nan()) {
return int_adapter<int_type>(not_a_number());
}
if((*this > 0 && rhs > 0) || (*this < min && rhs < min)) {
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < min_value)) {
return int_adapter<int_type>(pos_infinity());
}
if((*this > 0 && rhs < min) || (*this < min && rhs > 0)) {
if((*this > 0 && rhs < min_value) || (*this < min_value && rhs > 0)) {
return int_adapter<int_type>(neg_infinity());
}
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
@@ -440,22 +440,22 @@ private:
//! Assumes 'this' is a special value
int_adapter mult_div_specials(const int& rhs) const
{
int min;
int min_value;
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(is_signed) {
min = 0;
min_value = 0;
}
else {
min = 1;// there is no zero with unsigned
min_value = 1;// there is no zero with unsigned
}
if(this->is_nan()) {
return int_adapter<int_type>(not_a_number());
}
if((*this > 0 && rhs > 0) || (*this < min && rhs < 0)) {
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < 0)) {
return int_adapter<int_type>(pos_infinity());
}
if((*this > 0 && rhs < 0) || (*this < min && rhs > 0)) {
if((*this > 0 && rhs < 0) || (*this < min_value && rhs > 0)) {
return int_adapter<int_type>(neg_infinity());
}
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
+9 -9
View File
@@ -66,8 +66,8 @@ namespace date_time {
typedef point_rep point_type;
typedef duration_rep duration_type;
period(point_rep begin, point_rep end);
period(point_rep begin, duration_rep len);
period(point_rep first_point, point_rep end_point);
period(point_rep first_point, duration_rep len);
point_rep begin() const;
point_rep end() const;
point_rep last() const;
@@ -95,10 +95,10 @@ namespace date_time {
*/
template<class point_rep, class duration_rep>
inline
period<point_rep,duration_rep>::period(point_rep begin,
point_rep end) :
begin_(begin),
last_(end - duration_rep::unit())
period<point_rep,duration_rep>::period(point_rep first_point,
point_rep end_point) :
begin_(first_point),
last_(end_point - duration_rep::unit())
{}
//! create a period as [begin, begin+len)
@@ -106,9 +106,9 @@ namespace date_time {
*/
template<class point_rep, class duration_rep>
inline
period<point_rep,duration_rep>::period(point_rep begin, duration_rep len) :
begin_(begin),
last_(begin + len-duration_rep::unit())
period<point_rep,duration_rep>::period(point_rep first_point, duration_rep len) :
begin_(first_point),
last_(first_point + len-duration_rep::unit())
{}
@@ -114,10 +114,14 @@ namespace date_time {
typedef typename time_rep_type::date_type date_type;
typedef typename time_rep_type::date_duration_type date_duration_type;
template<class T> static void unused_var(const T&) {}
static time_rep_type get_time_rep(const date_type& day,
const time_duration_type& tod,
date_time::dst_flags dst=not_dst)
{
unused_var(dst);
return time_rep_type(day, tod);
}
static date_type get_date(const time_rep_type& val)
+17
View File
@@ -39,6 +39,23 @@ local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <defi
[ run gregorian/testparse_date.cpp <lib>../build/boost_date_time : : : $(DATE_TIME_PROPERTIES) ]
;
test-suite date_time_gregorian_dll
:
[ run gregorian/testdate.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testdate_dll ]
[ run gregorian/testdate_duration.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testdate_duration_dll ]
[ run gregorian/testperiod.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testperiod_dll ]
[ run gregorian/testdate_iterator.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testdate_iterator_dll ]
[ run gregorian/testfacet.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testfacet_dll ]
[ run gregorian/testformatters.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testformatters_dll ]
[ run gregorian/testgenerators.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testgenerators_dll ]
[ run gregorian/testgreg_cal.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testgreg_cal_dll ]
[ run gregorian/testgreg_day.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testgreg_day_dll ]
[ run gregorian/testgreg_month.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testgreg_month_dll ]
[ run gregorian/testgreg_year.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testgreg_year_dll ]
# this next test is commented out because it crashes on VC6 (cause unknown):
# [ run gregorian/testparse_date.cpp <dll>../build/boost_date_time : : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_DYN_LINK <runtime-link>dynamic : testparse_date_dll ]
;
test-suite date_time_posixtime
:
[ run posix_time/testlocal_adjustor.cpp