[DEV] add v1.76.0

This commit is contained in:
2021-10-05 21:37:46 +02:00
parent a97e9ae7d4
commit d0115b733d
45133 changed files with 4744437 additions and 1026325 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2119
doc/html/date_time/doxy.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,135 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>General Usage Examples</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../date_time.html" title="Chapter 13. Boost.Date_Time">
<link rel="prev" href="../../date_time.html" title="Chapter 13. Boost.Date_Time">
<link rel="next" href="../gregorian.html" title="Gregorian">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../date_time.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../gregorian.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="date_time.examples.general_usage_examples"></a>General Usage Examples</h2></div></div></div>
<p>
The following provides some sample usage of dates.
See <a class="link" href="../gregorian.html" title="Gregorian">Date Programming</a>
for more details.
</p>
<pre class="programlisting"><span class="keyword">using namespace</span> boost::gregorian;
date weekstart(<span class="number">2002</span>,Feb,<span class="number">1</span>);
date weekend = weekstart + weeks(<span class="number">1</span>);
date d2 = d1 + days(<span class="number">5</span>);
date today = day_clock::local_day();
if (d2 &gt;= today) {} <span class="comment">//date comparison operators</span>
date_period thisWeek(d1,d2);
<span class="keyword">if</span> (thisWeek.contains(today)) {}<span class="comment">//do something
//iterate and print the week</span>
day_iterator itr(weekstart);
<span class="keyword">while</span> (itr &lt;= weekend) {
std::cout &lt;&lt; (*itr) &lt;&lt; std::endl;
++itr;
}
<span class="comment">//input streaming</span>
std::stringstream ss(<span class="string">"2004-Jan-1"</span>);
ss &gt;&gt; d3;
<span class="comment">//date generator functions</span>
date d5 = next_weekday(d4, Sunday); <span class="comment">//calculate Sunday following d4
//US labor day is first Monday in Sept</span>
<span class="keyword">typedef</span> nth_day_of_the_week_in_month nth_dow;
nth_dow labor_day(nth_dow::first,Monday, Sep);
<span class="comment">//calculate a specific date for 2004 from functor</span>
date d6 = labor_day.get_date(<span class="number">2004</span>);
</pre>
<p>
The following provides some example code using times.
See <a class="link" href="../posix_time.html" title="Posix Time">Time Programming</a>
for more details.
</p>
<pre class="programlisting"><span class="keyword">using namespace</span> boost::posix_time;
date d(<span class="number">2002</span>,Feb,<span class="number">1</span>); <span class="comment">//an arbitrary date</span>
ptime t1(d, hours(<span class="number">5</span>)+nanosec(<span class="number">100</span>)); <span class="comment">//date + time of day offset</span>
ptime t2 = t1 - minutes(<span class="number">4</span>)+seconds(<span class="number">2</span>);
ptime now = second_clock::local_time(); <span class="comment">//use the clock</span>
date today = now.date(); <span class="comment">//Get the date part out of the time</span>
date tomorrow = today + date_duration(<span class="number">1</span>);
ptime tomorrow_start(tomorrow); <span class="comment">//midnight
//input streaming</span>
std::stringstream ss(<span class="string">"2004-Jan-1 05:21:33.20"</span>);
ss &gt;&gt; t2;
<span class="comment">//starting at current time iterator adds by one hour</span>
time_iterator titr(now,hours(<span class="number">1</span>));
<span class="keyword">for</span> (; titr &lt; tomorrow_start; ++titr) {
std::cout &lt;&lt; (*titr) &lt;&lt; std::endl;
}
</pre>
<p>
</p>
<p>
The following provides some example code using times.
See <a class="link" href="../local_time.html" title="Local Time">Local Time Programming</a>
for more details.
</p>
<pre class="programlisting">
<span class="keyword">using namespace</span> boost::local_time;
<span class="comment">//setup some timezones for creating and adjusting times
//first time zone uses the time zone file for regional timezone definitions</span>
tz_database tz_db;
tz_db.load_from_file(<span class="string">"date_time_zonespec.csv"</span>);
time_zone_ptr nyc_tz = tz_db.time_zone_from_region(<span class="string">"America/New_York"</span>);
<span class="comment">//This timezone uses a posix time zone string definition to create a time zone</span>
time_zone_ptr phx_tz(new posix_time_zone(<span class="string">"MST-07:00:00"</span>));
<span class="comment">//local departure time in phoenix is 11 pm on April 2 2005
// Note that New York changes to daylight savings on Apr 3 at 2 am)</span>
local_date_time phx_departure(date(<span class="number">2005</span>, Apr, <span class="number">2</span>), hours(<span class="number">23</span>), phx_tz,
local_date_time::NOT_DATE_TIME_ON_ERROR);
time_duration flight_length = hours(<span class="number">4</span>) + minutes(<span class="number">30</span>);
local_date_time phx_arrival = phx_departure + flight_length;
<span class="comment">//convert the phx time to a nyz time</span>
local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz);
<span class="comment">//2005-Apr-03 06:30:00 EDT</span>
std::cout &lt;&lt; nyc_arrival &lt;&lt; std::endl;
</pre>
<p>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
<code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../date_time.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../date_time.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../gregorian.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Serialization</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../date_time.html" title="Chapter 13. Boost.Date_Time">
<link rel="prev" href="date_time_io.html" title="Date Time Input/Output">
<link rel="next" href="details.html" title="Details">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
<td align="center"><a href="../../../index.html">Home</a></td>
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="date_time_io.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="details.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="date_time.serialization"></a>Serialization</h2></div></div></div>
<p>
The boost::date_time library is compatible with the boost::serialization library's text and xml archives. The list of classes that are serializable are:
</p>
<h4>
<a name="id-1.3.14.12.3"></a>boost::gregorian</h4>
<div class="informaltable"><table class="table" width="100%">
<colgroup>
<col>
<col>
<col>
</colgroup>
<tbody>
<tr>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_class" title="Date">date</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_duration" title="Date Duration (aka Days)">date_duration</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_period" title="Date Period">date_period</a></td>
</tr>
<tr>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">partial_date</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">nth_day_of_week_in_month</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">first_day_of_week_in_month</a></td>
</tr>
<tr>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">last_day_of_week_in_month</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">first_day_of_week_before</a></td>
<td><a class="link" href="gregorian.html#date_time.gregorian.date_algorithms" title="Date Generators/Algorithms">first_day_of_week_after</a></td>
</tr>
<tr>
<td>greg_month</td>
<td>greg_day</td>
<td>greg_weekday</td>
</tr>
</tbody>
</table></div>
<h4>
<a name="id-1.3.14.12.5"></a>boost::posix_time</h4>
<div class="informaltable"><table class="table" width="100%">
<colgroup>
<col>
<col>
<col>
</colgroup>
<tbody><tr>
<td><a class="link" href="posix_time.html#date_time.posix_time.ptime_class" title="Ptime">ptime</a></td>
<td><a class="link" href="posix_time.html#date_time.posix_time.time_duration" title="Time Duration">time_duration</a></td>
<td><a class="link" href="posix_time.html#date_time.posix_time.time_period" title="Time Period">time_period</a></td>
</tr></tbody>
</table></div>
<p>
No extra steps are required to build the date_time library for serialization use.
</p>
<p>NOTE: due to a change in the serialization library interface, it is now required that all streamable objects be const prior to writing to the archive. The following template function will allow for this (and is used in the date_time tests). At this time no special steps are necessary to read from an archive.
</p>
<pre class="programlisting">
template&lt;class archive_type, class temporal_type&gt;
void save_to(archive_type&amp; ar, const temporal_type&amp; tt)
{
ar &lt;&lt; tt;
}
</pre>
<p>
</p>
<p>
Example text_archive usage:
</p>
<pre class="programlisting">
using namespace boost::posix_time;
using namespace boost::gregorian;
ptime pt(date(2002, Feb, 14)), hours(10)), pt2(not_a_date_time);
std::ofstream ofs("tmp_file");
archive::test_oarchive oa(ofs);
save_to(oa, pt); // NOTE: no macro
ofs.close();
std::ifstream ifs("tmp_file");
archive::text_iarchive ia(ifs);
ia &gt;&gt; pt2; // NOTE: no macro
ifs.close();
pt == pt2; // true</pre>
<p>
</p>
<p>
Example xml_archive usage:
</p>
<pre class="programlisting">
using namespace boost::gregorian;
date d(2002, Feb, 14), d2(not_a_date_time);
std::ofstream ofs("tmp_file");
archive::xml_oarchive oa(ofs);
save_to(oa, BOOST_SERIALIZATION_NVP(d)); // macro required for xml_archive
ofs.close();
std::ifstream ifs("tmp_file");
archive::xml_iarchive ia(ifs);
ia &gt;&gt; BOOST_SERIALIZATION_NVP(d2); // macro required for xml_archive
ifs.close();
d == d2; // true</pre>
<p>
</p>
<p>
To use the date_time serialization code, the proper header files must be explicitly included. The header files are:
</p>
<pre class="programlisting">
boost/date_time/gregorian/greg_serialize.hpp</pre>
<p>
and
</p>
<pre class="programlisting">
boost/date_time/posix_time/time_serialize.hpp</pre>
<p>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2005 CrystalClear Software, Inc<p>Subject to the Boost Software License, Version 1.0. (See accompanying file
<code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="date_time_io.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../date_time.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="details.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>