mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-29 19:32:20 +00:00
171 lines
6.7 KiB
XML
171 lines
6.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
|
|
"../../../tools/boostbook/dtd/boostbook.dtd">
|
|
|
|
<!-- Copyright (c) 2001-2004 CrystalClear Software, Inc.
|
|
Subject to the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
|
|
-->
|
|
|
|
<section id="date_time.gregorian.date_algorithms">
|
|
<title>Date Generators/Algorithms</title>
|
|
<bridgehead renderas="sect2">Date Generators/Algorithms</bridgehead>
|
|
<link linkend="algo_intro">Introduction</link> --
|
|
<link linkend="algo_header">Header</link> --
|
|
<link linkend="algo_overview">Class Overview</link> --
|
|
<link linkend="algo_func_overview">Function Overview</link>
|
|
|
|
<anchor id="algo_intro" />
|
|
<bridgehead renderas="sect3">Introduction</bridgehead>
|
|
<para>
|
|
Date algorithms or generators are tools for generating other dates or schedules of dates. A generator function starts with some part of a date such as a month and day and is supplied another part to then generate a concrete date. This allows the programmer to represent concepts such as "The first Sunday in February" and then create a concrete set of dates when provided with one or more years.
|
|
<emphasis>Note</emphasis>: As of boost version 1_31_0, date generator names have been changed. Old names are still available but are no longer documented and may someday be deprecated
|
|
</para>
|
|
<para>Also provided are stand-alone functions for generating a date, or calculation a duration of days. These functions take a date object and a weekday object as parameters.
|
|
</para>
|
|
<para>All date generator classes and functions are in the boost::gregorian namespace.
|
|
</para>
|
|
<para>
|
|
The <link linkend="date_time.examples.print_holidays">print holidays</link> example shows a detailed usage example.
|
|
</para>
|
|
|
|
<anchor id="algo_header" />
|
|
<bridgehead renderas="sect3">Header</bridgehead>
|
|
<para>
|
|
#include "boost/date_time/date_generators.hpp"
|
|
</para>
|
|
|
|
<anchor id="algo_overview" />
|
|
<bridgehead renderas="sect3">Overview</bridgehead>
|
|
<informaltable frame="all">
|
|
<tgroup cols="4">
|
|
<thead>
|
|
<row>
|
|
<entry>Class</entry>
|
|
<entry>Construction Parameters</entry>
|
|
<entry>get_date Parameter</entry>
|
|
<entry>Description</entry>
|
|
<entry>Example</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>year_based_generator</entry>
|
|
<entry>abstract base class</entry>
|
|
<entry>greg_year year</entry>
|
|
<entry>A unifying date_generator base type for: partial_date, nth_day_of_the_week_in_month, first_day_of_the_week_in_month, and last_day_of_the_week_in_month
|
|
</entry>
|
|
<entry>
|
|
The <link linkend="date_time.examples.print_holidays">print holidays</link> example shows a detailed usage example.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>last_day_of_the_week_in_month</entry>
|
|
<entry>greg_weekday or weekday, greg_month or month</entry>
|
|
<entry>greg_year or year</entry>
|
|
<entry>Calculate something like last Monday of January</entry>
|
|
<entry>
|
|
last_day_of_the_week_in_month lwdm(Monday,Jan);
|
|
date d = lwdm.get_date(2002);//2002-Jan-28
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>first_day_of_the_week_in_month</entry>
|
|
<entry>greg_weekday or weekday, greg_month or month</entry>
|
|
<entry>greg_year or year</entry>
|
|
<entry>Calculate something like first Monday of January</entry>
|
|
<entry>
|
|
first_day_of_the_week_in_month fdm(Monday,Jan);
|
|
date d = fdm.get_date(2002);//2002-Jan-07
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>partial_date</entry>
|
|
<entry>greg_day, greg_month or month</entry>
|
|
<entry>greg_year</entry>
|
|
<entry>Generates a date by applying the year to the given month and day.</entry>
|
|
<entry>
|
|
partial_date pd(1,Jan);
|
|
date d = pd.get_date(2002);//2002-Jan-01
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>first_day_of_the_week_after</entry>
|
|
<entry> greg_weekday or weekday</entry>
|
|
<entry><link linkend="date_time.gregorian.date_class">date</link></entry>
|
|
<entry>Calculate something like First Sunday after Jan 1,2002</entry>
|
|
<entry>
|
|
first_day_of_the_week_after fdaf(Monday);
|
|
date d = fdaf.get_date(date(2002,Jan,1));//2002-Jan-07
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>first_day_of_the_week_before</entry>
|
|
<entry> greg_weekday or weekday</entry>
|
|
<entry><link linkend="date_time.gregorian.date_class">date</link></entry>
|
|
<entry>Calculate something like First Monday before Feb 1,2002</entry>
|
|
<entry>
|
|
first_day_of_the_week_before fdbf(Monday);
|
|
date d = fdbf.get_date(date(2002,Feb,1));//2002-Jan-28
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
|
|
|
|
<anchor id="algo_func_overview" />
|
|
<bridgehead renderas="sect3">Function Overview</bridgehead>
|
|
<informaltable frame="all">
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>Function Prototype</entry>
|
|
<entry>Description</entry>
|
|
<entry>Example</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><link linkend="date_time.gregorian.date_duration">days</link> days_until_weekday (const <link linkend="date_time.gregorian.date_class">date</link>&, const greg_weekday&)</entry>
|
|
<entry> Calculates the number of days from given date until given weekday.</entry>
|
|
<entry>
|
|
date d(2004,Jun,1); // Tuesday
|
|
greg_weekday gw(Friday);
|
|
days_until_weekday(d, gw); // 3 days
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="date_time.gregorian.date_duration">days</link> days_before_weekday (const <link linkend="date_time.gregorian.date_class">date</link>&, const greg_weekday&)</entry>
|
|
<entry> Calculates the number of day from given date to previous given weekday.</entry>
|
|
<entry>
|
|
date d(2004,Jun,1); // Tuesday
|
|
greg_weekday gw(Friday);
|
|
days_before_weekday(d, gw); // 4 days
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="date_time.gregorian.date_class">date</link> next_weekday (const <link linkend="date_time.gregorian.date_class">date</link>&, const greg_weekday&)</entry>
|
|
<entry> Generates a date object representing the date of the following weekday from the given date.</entry>
|
|
<entry>
|
|
date d(2004,Jun,1); // Tuesday
|
|
greg_weekday gw(Friday);
|
|
next_weekday(d, gw); // 2004-Jun-4
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><link linkend="date_time.gregorian.date_class">date</link> previous_weekday (const <link linkend="date_time.gregorian.date_class">date</link>&, const greg_weekday&)</entry>
|
|
<entry> Generates a date object representing the date of the previous weekday from the given date.</entry>
|
|
<entry>
|
|
date d(2004,Jun,1); // Tuesday
|
|
greg_weekday gw(Friday);
|
|
previous_weekday(d, gw); // 2004-May-28
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
|
|
<link linkend="top">top</link>
|
|
</section>
|