From b22d572c70b191aebeef78a26fc545d5a578d9aa Mon Sep 17 00:00:00 2001 From: Jeff Garland Date: Thu, 22 Aug 2002 00:11:01 +0000 Subject: [PATCH] updated documentation [SVN r15046] --- doc/BasicTerms.html | 92 ++++++++ doc/BuildInfo.html | 113 ++++++++++ doc/DateTimeConcepts-Calculations.html | 94 ++++++++ doc/DesignGoals.html | 108 +++++++++ doc/References.html | 196 +++++++++++++++++ doc/Tradeoffs.html | 163 ++++++++++++++ doc/class_date.html | 198 +++++++++++++++++ doc/class_date_duration.html | 111 ++++++++++ doc/class_date_period.html | 180 +++++++++++++++ doc/class_greg_base_facet.html | 67 ++++++ doc/class_gregorian_calendar.html | 87 ++++++++ doc/class_ptime.html | 188 ++++++++++++++++ doc/class_time_duration.html | 199 +++++++++++++++++ doc/class_time_period.html | 179 +++++++++++++++ doc/date_algorithms.html | 93 ++++++++ doc/date_iterators.html | 83 +++++++ doc/dates__as__strings_8cpp-example.html | 73 +++++++ doc/days__alive_8cpp-example.html | 48 ++++ doc/days__till__new__year_8cpp-example.html | 31 +++ doc/doxygen.css | 26 +++ doc/gregorian.html | 78 +++++++ doc/index.html | 219 +++++++++++++++++++ doc/local__utc__conversion_8cpp-example.html | 98 +++++++++ doc/local_time_adjust.html | 92 ++++++++ doc/period__calc_8cpp-example.html | 91 ++++++++ doc/posix_time.html | 57 +++++ doc/print__holidays_8cpp-example.html | 113 ++++++++++ doc/print__hours_8cpp-example.html | 59 +++++ doc/print__month_8cpp-example.html | 62 ++++++ doc/time__math_8cpp-example.html | 40 ++++ doc/time__periods_8cpp-example.html | 62 ++++++ doc/time_duration_inherit.png | Bin 0 -> 2033 bytes doc/time_iterators.html | 78 +++++++ 33 files changed, 3378 insertions(+) create mode 100644 doc/BasicTerms.html create mode 100644 doc/BuildInfo.html create mode 100644 doc/DateTimeConcepts-Calculations.html create mode 100644 doc/DesignGoals.html create mode 100644 doc/References.html create mode 100644 doc/Tradeoffs.html create mode 100644 doc/class_date.html create mode 100644 doc/class_date_duration.html create mode 100644 doc/class_date_period.html create mode 100644 doc/class_greg_base_facet.html create mode 100644 doc/class_gregorian_calendar.html create mode 100644 doc/class_ptime.html create mode 100644 doc/class_time_duration.html create mode 100644 doc/class_time_period.html create mode 100644 doc/date_algorithms.html create mode 100644 doc/date_iterators.html create mode 100644 doc/dates__as__strings_8cpp-example.html create mode 100644 doc/days__alive_8cpp-example.html create mode 100644 doc/days__till__new__year_8cpp-example.html create mode 100644 doc/doxygen.css create mode 100644 doc/gregorian.html create mode 100644 doc/index.html create mode 100644 doc/local__utc__conversion_8cpp-example.html create mode 100644 doc/local_time_adjust.html create mode 100644 doc/period__calc_8cpp-example.html create mode 100644 doc/posix_time.html create mode 100644 doc/print__holidays_8cpp-example.html create mode 100644 doc/print__hours_8cpp-example.html create mode 100644 doc/print__month_8cpp-example.html create mode 100644 doc/time__math_8cpp-example.html create mode 100644 doc/time__periods_8cpp-example.html create mode 100644 doc/time_duration_inherit.png create mode 100644 doc/time_iterators.html diff --git a/doc/BasicTerms.html b/doc/BasicTerms.html new file mode 100644 index 0000000..34a6992 --- /dev/null +++ b/doc/BasicTerms.html @@ -0,0 +1,92 @@ + + +Date-Time Terminology + + + + + +C++ Boost + + +

Date-Time Terminology

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+

+The following are a number of terms relevant to the date-time domain. +

+

A taxonomy of temporal types: +

+

And some other terms: +

+

Some standard date-time terminology: +

+

Some more experimental ones: +

+

These are design sorts of terms: +

+ + + +
+
+ +Last modified: Wed Aug 21 15:05:22 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/BuildInfo.html b/doc/BuildInfo.html new file mode 100644 index 0000000..789caa4 --- /dev/null +++ b/doc/BuildInfo.html @@ -0,0 +1,113 @@ + + +Boost Date-Time Build-Compiler Information + + + + + +C++ Boost + +

Date-Time Build-Compiler Information

+

 

+
+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Overview -- +Compilation Options -- +Compiler/Portability Notes -- +Directory Structure -- +Required Boost Libraries +

+

Overview

+

+The library has several functions that require the creation of a library file. +The Jamfile in the build directory will produce a library +(libboost_date_time) that contains these functions. + +

+

Compilation Options

+

+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 +for many applications that do not require nano-second resolutions. +

+The variable BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG, as defined in +build/Jamfile, selects between these options. To select the 64 bit +integer implementation simply remove this define from the Jamfile. + +

+

Compiler/Portability Notes

+

+The Boost Date-Time library has been built and tested with many compilers. +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: +

+

+In particular, a lack of support for standard locales limits the ability +of the library to support iostream based input output. For these +compilers a set of more limited string based input-output is provided. + +The compilers/stadard libraries with this limitation include: +

+

+ +Other compilers such as Comeau and Metroworks have been tested +sucessfully with earlier versions of the library. + +

+

Directory Structure

+

+The date_time directory structure has been changed for boost submission. +

+The directory tree has the following structure: +

+  /boost/date_time                    -- common headers and template code
+  /boost/date_time/gregoran           -- gregorian calendar system header files
+  /boost/date_time/posix_time         -- posix time system headers
+  /libs/date_time/build               -- build files and output directory
+  /libs/date_time/test                -- test battery for generic code
+  /libs/date_time/test/gregorian      -- test battery for the gregorian system
+  /libs/date_time/examples/gregorian  -- nifty example programs
+  /libs/date_time/src/gregorian       -- cpp files for libboost_date_time
+  /libs/date_time/test/posix_time     -- test battery for the posix_time system
+  /libs/date_time/examples/posix_time -- time example programs
+  /libs/date_time/src/posix_time      -- empty (one file, but no source code...)
+
+

+ +

Required Boost Libraries

+ +

+The library depends on +

+ so at least these libraries need to be installed. + +
+
+ +Last modified: Wed Aug 21 15:08:31 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + diff --git a/doc/DateTimeConcepts-Calculations.html b/doc/DateTimeConcepts-Calculations.html new file mode 100644 index 0000000..6c39721 --- /dev/null +++ b/doc/DateTimeConcepts-Calculations.html @@ -0,0 +1,94 @@ + + +Date-Time Concepts - Calculation + + + + + +C++ Boost + + +

Date-Time Concepts - Calculation

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Timepoints -- +Durations -- +Interval -- +Special Cases +

+ +

Timepoints

+ +

+This section describes some of basic arithmetic rules that can be performed with GDTL timepoints. + +

+ Timepoint + Duration --> Timepoint
+ Timepoint - Duration --> Timepoint
+ 
+ Duration + Timepoint --> Undefined 
+ Duration - Timepoint --> Undefined
+ 
+ Timepoint + Timepoint --> Undefined
+ Timepoint - Timepoint --> Duration
+
+

+

Durations

+

+This section describes standard operations for a time duration. +

+ Duration + Duration  --> Duration
+ Duration - Duration  --> Duration
+
+ Duration * Integer   --> Duration  
+ Integer  * Duration  --> Duration  
+
+ Duration(∞) * Integer --> Duration(∞) 
+ Duration(∞)/Integer   --> Duration(∞) 
+
+

+ + +

+

Intervals

+

+Here are the "operations" supported by intervals. They are based on half-open +range. + +

 
+ //These can be defined by either of 2 Timepoints or a Timepoint and Duration
+ Timeinterval intersects Timeinterval --> bool
+ Timeinterval intersection Timeinterval --> Timeperiod //results undefined if no intersection 
+ Timeinterval contains  Timepoint    --> bool
+ Timeinterval contains  Timeinterval --> bool  
+ Timeinterval shift Duration         --> shift start and end by duration amount
+ 
+
+ +

+

Special Cases

+ +

In general special values such as Not A Date Time (NADT) and infinity should follow rules like floating point values. Note that it should be possible to +configure NADT based systems to throw an exception instead of result in NADT. +

+ Timepoint(NADT) + Duration --> Timepoint(NADT)
+ Timepoint(∞) + Duration --> Timepoint(∞)
+ Timepoint + Duration(∞) --> Timepoint(∞)
+ Timepoint - Duration(∞) --> Timepoint(-∞)
+
+ +
+
+ +Last modified: Wed Aug 21 15:40:36 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/DesignGoals.html b/doc/DesignGoals.html new file mode 100644 index 0000000..095031f --- /dev/null +++ b/doc/DesignGoals.html @@ -0,0 +1,108 @@ + + +Overall Design Goals + + + + + +C++ Boost + + +

Overall Design Goals

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CategoryDescriptionFunctions
InterfacesProvide concrete classes for manipulation of dates and times +
    +
  • date, time, date_duration, time_duration, date_period, time_period, etc +
  • support for infinity - positive infinity, negative infinity +
  • iterators over time and date ranges +
  • allow date and time implemenations to be separate as much as possible +
+
CalculationProvide a basis for performing efficient time calculations +
    +
  • days between dates +
  • durations of times +
  • durations of dates and times together +
+
Representation FlexibilityProvide the maximum possible reusability and flexibility +
    +
  • traits based customization of internal + representations for size versus resolution control +
  • Allowing the use of different epochs and resolution + (eg: seconds versus microseconds, dates starting at the + year 2000 versus dates starting in 1700) +
  • Options for configuring unique calendar + representations (Gregorian + others) +
  • the use of Julian Day number and the conversion between this and the Gregorian/Julian calendar date +
  • Allow for flexible adjustments including + leap seconds +
+
Date CalculationsProvide tools for date calculations +
    +
  • provide basis for calculation of complex event specs like holidays +
  • calendar to calendar conversions +
  • provide for ability to extend to new calendar systems +
+
Time CalculationsProvide concrete classes for manipulation of time +
    +
  • provide the ability to handle cross time-zone issues +
  • provide adjustments for daylight savings time (summer time) +
+
Clock InterfacesProvide classes for retrieving time current time +
    +
  • access to a network / high resolution time sources +
  • retrieving the current date time information to populate classes +
+
I/O InterfacesProvide input and output for time including +
    +
  • multi-lingual support +
  • provide ISO8601 compliant time facet +
  • use I/O facets for different local behavior +
+
+ +


+
+ +Last modified: Wed Aug 21 15:42:19 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/References.html b/doc/References.html new file mode 100644 index 0000000..2250d03 --- /dev/null +++ b/doc/References.html @@ -0,0 +1,196 @@ + + +Date-Time References + + + + + +C++ Boost + + +

Date-Time References

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+

+The following are a number of references and sources of information about the +date-time domain. +

+

+
+

Date Calendar References

+

+

+
+ +

Time

+ +

+

+

+


+ +

Other C/C++ Libraries

+ +

+

+


+ +

JAVA Date & Time Library Quick Reference

+

+

+
+ +

Scripting Language Libraries

+ +
+ +

Related Commercial and Fanciful Pages

+ +
+ +

Resolution, Precision, and Accuracy

+ + + +
+
+ +Last modified: Wed Aug 21 15:55:17 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/Tradeoffs.html b/doc/Tradeoffs.html new file mode 100644 index 0000000..bef6e3f --- /dev/null +++ b/doc/Tradeoffs.html @@ -0,0 +1,163 @@ + + + + + Date-Time Concepts - Theoretical Foundations + + + + + +C++ Boost + +

Tradeoffs: Stability, Predictability, and Approximations

+

 

+
+Overall Index -- +Gregorian Index -- +Posix Time Index +

+ +

Unavoidable Trade-offs

+ +

+The library does its best to provide everything a user could want, but there are certain inherent constraints that limit what any temporal library can do. Specifically, a user much choose which two of the following three capabilities are desired in any particular application: +

+Some libraries may implicitly promise to deliver all three, but if you actually put them to the test, only two can be true at once. This limitation is not a deficiency in the design or implementation of any particular library; rather it is a consequence of the way different time systems are defined by international standards. Let's look at each of the three cases: +

+If you want exact agreement with wall-clock time, you must use either UTC or local time. If you compute a duration by subtracting one UTC time from another and you want an answer accurate to the second, the two times must not be too far in the future because leap seconds affect the count but are only determined about 6 months in advance. With local times a future duration calculation could be off by an entire hour, since legislatures can and do change DST rules at will. +

+If you want to handle wall-clock times in the future, you won't be able (in the general case) to calculate exact durations, for the same reasons described above. +

+If you want accurate calculations with future times, you will have to use TAI or an equivalent, but the mapping from TAI to UTC or local time depends on leap seconds, so you will not have exact agreement with wall-clock time. +

+

Stability, Predictability, and Approximations

+ +

+Here is some underlying theory that helps to explain what's going on. +Remember that a temporal type, like any abstract data type (ADT), +is a set of values together with operations on those values. +

+

Stability

+ +

+The representation of a type is stable if the bit pattern associated with a given value does not change over time. +A type with an unstable representation is unlikely to be of much +use to anyone, so we will insist that any temporal library use +only stable representations. +

+An operation on a type is stable if the result of applying the operation to a particular operand(s) does not change over time. +

+

Predictability

+ +

+ +Sets are most often classified into two categories: well-defined +and ill-defined. Since a type is a set, we can extend these definitions +to cover types. For any type T, there must be a predicate +is_member( x ) +which determines whether a value x is a member of type T. +This predicate must return true, false, or dont_know. +

+If for all x, is_member( x ) returns either true or false, we +say the set T is well-defined. +

+If for any x, is_member( x ) returns dont_know, we say the +set T is ill-defined. +

+Those are the rules normally used in math. However, +because of the special characteristics of temporal +types, it is useful to refine this view and create a third category +as follows: +

+For any temporal type T, there must be a predicate is_member( x, t ) +which determines whether a value x is a member of T. +The parameter t represents the time when the predicate is evaluated. +For each xi, there must be a time ti and a value v +such that: +

+ti is thus the time when we "find out" whether xi is a +member of T. +Now we can define three categories of temporal types: +

+If for all xi, ti = negative infinity, +we say the type T is predictable. +

+If for some xi, ti = positive infinity, +we say the type T is ill-formed. +

+Otherwise we say the type T is unpredictable (this +implies that for some xi, ti is finite). +

+Ill-formed sets are not of much practical use, so we will +not discuss them further. In plain english the above +simply says that all the values of a predictable type are +known ahead of time, but some values of an unpredictable +type are not known until some particular time. + +

+

Stability of Operations

+ +

+Predictable types have a couple of important properties: +

+The practical effect of this is that duration calculations +can be implemented with simple integer subtraction. +Examples of predictable types are TAI timepoints and +Gregorian dates. +

+Unpredictable types have exactly the opposite properties: +

+Examples of unpredictable types are UTC timepoints and +Local Time timepoints. +

+We can refine this a little by saying that a range within +an unpredicatable type can be predictable, and operations performed +entirely on values within that range will be stable. +For example, the range of UTC timepoints from 1970-01-01 +through the present is predictable, so calculations of durations within that range will be stable. +

+

Approximations

+ +

+These limitations are problematical, because important temporal +types like UTC and Local Time are in fact unpredictable, and +therefore operations on them are sometimes unstable. Yet as a practical matter we often want to perform this kind of operation, such as computing the duration between two timepoints in the future that are specified in Local Time. +

+The best the library can do is to provide an approximation, +which is generally possible and for most purposes will be +good enough. Of course the documentation must specify when +an answer will be approximate (and thus unstable) and how +big the error may be. In many respects calculating with unpredictable sets is analogous to the use of floating point numbers, for which results are expected to only be approximately correct. Calculating with predictable sets would then be +analagous to the user of integers, where results are expected +to be exact. +

+For situations where exact answers are required or instability cannot be tolerated, the user must +be able to specify this, and then the library should throw an +exception if the user requests a computation for which an +exact, stable answer is not possible. +

+ +


+
+ +Last modified: Wed Aug 21 14:46:55 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + diff --git a/doc/class_date.html b/doc/class_date.html new file mode 100644 index 0000000..8386b1b --- /dev/null +++ b/doc/class_date.html @@ -0,0 +1,198 @@ + + +gregorian::date Documentation + + + + + +C++ Boost + + +

gregorian::date

+

 

+


+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Documentation +

+Header -- +Construction -- +Construct from String -- + Construct from Clock -- +Accessors -- +Conversion To String -- +Operators +

+

Introduction

+ +

+The class boost::gregorian::date is the primary interface for library users. In general, the date class is immutable once constructed although it does allow assignment. + +

+Other techniques for creating dates include date iterators and date algorithms or generators. + +

+ +

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+

Construction

+ + +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
date(greg_year year, greg_month month, greg_day day)Construct from parts of date. Throws bad_year, + bad_day_of_month, or bad_day_month (derivatives + of std::out_of_range) if + the year, month or day are out of range. + date d(2002,Jan,10)
date(date d)Copy constructordate d1(d)
date(special_values sv)Constructor for infinitites, not-a-date-time, max_date, and min_datedate d1(neg_infin);
date d2(pos_infin);
date d3(not_a_date_time);
date d4(max_date);
date d5(min_date);
+ +

+

Construction From String

+ + +

+ + + + + + + + + +
SyntaxDescriptionExample
date from_string(const std::string&)From delimited date string where with order year-month-day eg: 2002-1-25std::string ds("2002/1/25");
+ date d(from_string(ds))
date from_undelimited_string(const std::string&)From iso type date string where with order year-month-day eg: 20020125std::string ds("20020125");
+ date d(from_string(ds))
+

+ +

Construction From Clock

+ +

+ + + + + + + + +
SyntaxDescriptionExample
day_clock::local_day()Get the local day based on the time zone settings of the computer.date d(day_clock::local_day())
day_clock::universal_day()Get the UTC day.date d(day_clock::universal_day())
+ +

+ +

Accessors

+ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
greg_year year() constGet the year part of the date.date d(2002,Jan,10); d.year() --> 2002;
greg_month month() constGet the month part of the date.date d(2002,Jan,10); d.month() --> 1;
greg_day day() constGet the day part of the date.date d(2002,Jan,10); d.day() --> 10;
greg_ymd year_month_day() constReturn a year_month_day struct. More efficient when all 3 parts of the date are needed.date d(2002,Jan,10); +
date::ymd_type ymd = d.year_month_day(); +
ymd.year --> 2002, ymd.month --> 1, ymd.day --> 10
greg_day_of_week day_of_week() constGet the day of the week (eg: Sunday, Monday, etc.date d(2002,Jan,10); d.day() --> Thursday;
bool is_infinity() constReturns true if date is either possitive or negative infinitydate d(pos_infin); d.is_infinity() --> true;
bool is_neg_infinity() constReturns true if date is negative infinitydate d(neg_infin); d.is_neg_infinity() --> true;
bool is_pos_infinity() constReturns true if date is positive infinitydate d(neg_infin); d.is_pos_infinity() --> true;
bool is_not_a_date() constReturns true if value is not a datedate d(not_a_date_time); d.is_not_a_date() --> true;
+ +

+

Conversion To String

+ +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
std::string to_simple_string(date d)To YYYY-mmm-DD string where mmm 3 char month name.2002-Jan-01
std::string to_iso_string(date d)To YYYYMMDD where all components are integers.20020131
std::string to_iso_extended_string(date d)To YYYY-MM-DD where all components are integers.2002-01-31
+

+ + +

Operators

+ + +

+ + + + + + + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
operator>, operator< +
operator>=, operator<=
A full complement of comparison operatorsd1 == d2, etc
date operator+(date_duration) constReturn a date adding a day offsetdate d(2002,Jan,1); +
date_duration dd(1); +
date d2 = d + dd;
date operator-(date_duration) constReturn a date by adding a day offset date d(2002,Jan,1); +
date_duration dd(1); +
date d2 = d - dd;
date_duration operator-(date) constReturn a date duration by subtracting two datesdate d1(2002,Jan,1); +
date d2(2002,Jan,2); +
date_duration dd = d2-d1;
+ +


+
+ +Last modified: Wed Aug 21 15:11:00 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_date_duration.html b/doc/class_date_duration.html new file mode 100644 index 0000000..c43c7dd --- /dev/null +++ b/doc/class_date_duration.html @@ -0,0 +1,111 @@ + + +gregorian::date_duration Documentation + + + + + +C++ Boost + + +

gregorian::date_duration

+
+

+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Documentation +

+Header -- +Construction -- +Accessors -- +Operators +

+

Introduction

+ +

+The class boost::gregorian::date_duration is a simple day count used for arithmetic with gregorian::date. A duration can be either positive or negative. +

+ +

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+

+ +

Construction

+ + +

+ + + + + +
SyntaxDescriptionExample
date_duration(long)Create a duration count.date_duration dd(3); //3 days
+ +

+ +

Accessors

+ + +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
long days() constGet the day count.date_duration dd(3); dd.days() --> 3
bool is_negative() constTrue if number of days is less than zero..date_duration dd(-1); dd.is_negative() --> true
static date_duration unit()Return smallest possible unit of duration type.date_duration::unit() --> date_duration(1)
+ +

+ +

Operators

+ + +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
+ operator>, operator<
+ operator>=, operator<=
A full complement of comparison operatorsdd1 == dd2, etc
date_duration operator+(date_duration) constAdd date durations.date_duration dd1(3); +
date_duration dd2(5); +
date_duration dd3 = dd1 + dd2;
date_duration operator-(date_duration) constSubtract durations.date_duration dd1(3); +
date_duration dd2(5); +
date_duration dd3 = dd1 - dd2;
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:12:43 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_date_period.html b/doc/class_date_period.html new file mode 100644 index 0000000..9107325 --- /dev/null +++ b/doc/class_date_period.html @@ -0,0 +1,180 @@ + + +gregorian::date_period Documentation + + + + + +C++ Boost + +

gregorian::date_period

+

 

+
+

+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Period Documentation +

+Header -- +Construction -- +Accessors -- +Conversion To String -- +Operators -- +

+

Introduction

+ +

+The class boost::gregorian::date_period provides direct representation +for ranges between two dates. Periods provide the ability to simplify +some types of caculations by simplifing the conditional logic of the +program. For example, testing if a date is within an irregular +schedule such as a weekend or holiday can be accomplished using +collections of date periods. This is facilitated by several methods +that allow evaluation if a date_period intersects with another date +period, and to generate the period resulting from the intersection. +The period calculation +example provides an example of this. + + +

+Date periods used in combination with infinity values have the abilty +to represent complex concepts such as 'until further notice'. + +

+

+

+

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+ +

+

Construction

+

+ + + + + + + + + + + + +
SyntaxDescriptionExample
date_period(date begin, date last) + Create a period as [begin, last). If last is <= begin then + the period will be defined as null. + date_period dp(date(2002,Jan,10), date_duration(2));
date_period(date start, date end) + Create a period as [begin, begin+len). If len is <= zero then + the period will be defined as null. + date_period dp(date(2002,Jan,10), date_duration(2));
date_period(date_period rhs)Copy constructordate_period dp1(dp)
+ +

+ +

+ +

Accessors

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
date begin() constReturn first day of period.date_period dp(date(2002,Jan,1), date(2002,Jan,10));
+ dp.begin() --> 2002-Jan-01
date last() constReturn last date in the perioddate_period dp(date(2002,Jan,1), date(2002,Jan,10));
+ dp.last() --> 2002-Jan-09
date end() constReturn one past the last in perioddate_period dp(date(2002,Jan,1), date(2002,Jan,10));
+ dp.end() --> 2002-Jan-10
bool is_null() constTrue if period is not well formed. eg: start less than end date_period dp(date(2002,Jan,10), date(2002,Jan,1));
+ dp.begin() --> true
bool contains(date) constTrue if date is within the perioddate_period dp(date(2002,Jan,1), date(2002,Jan,10));
+ dp.contains(date(2002,Jan,2)) --> true
bool contains(date_period) constTrue if date period is within the perioddate_period dp1(date(2002,Jan,1), date(2002,Jan,10));
+ date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
+ dp1.contains(dp2) --> true
+ dp2.contains(dp1) --> false
bool intersects(date_period) constTrue if periods overlapdate_period dp1(date(2002,Jan,1), date(2002,Jan,10));
+ date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
+ dp2.intersects(dp1) --> true
date_period intersection(date_period) constCalculate the intersection of 2 periods. Null if no intersection.date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
+ date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
+ dp2.intersects(dp1) --> dp2
date_period merge(date_period) constReturns union of two periods. Null if no intersection.date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
+ date_period dp2(date(2002,Jan,9), date(2002,Jan,31));
+ dp2.intersects(dp1) --> 2002-Jan-01/2002-Jan-31
date_period shift(date_duration)Add duration to both start and end.date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
+ dp1.shift(date_duration(1)); --> 2002-Jan-02/2002-Jan-11
+

+

Conversion To String

+ +

+ + + + + + +
SyntaxDescriptionExample
std::string to_simple_string(date_period dp)To [YYYY-mmm-DD/YYYY-mmm-DD] string where mmm is 3 char month name.[2002-Jan-01/2002-Jan-31]
+

+ + +

Operators

+ + +

+ + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
operator>, operator< +
A full complement of comparison operatorsdp1 == dp2, etc
operator<True if dp1.end() less than dp2.begin()dp1 < dp2, etc
operator>True if dp1.begin() greater than dp2.end()dp1 > dp2, etc
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:15:28 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_greg_base_facet.html b/doc/class_greg_base_facet.html new file mode 100644 index 0000000..b2a72bd --- /dev/null +++ b/doc/class_greg_base_facet.html @@ -0,0 +1,67 @@ + + +Date I/O Documentation + + + + + +C++ Boost + +

Date Input/Output

+

 

+
+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Introduction -- +Class Overview +

+

Introduction

+

+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 +build information page for details. +

+ +

+

Class Overview

+

+ + + + + + + + + + + + + + + + + + + +
ClassConstruction ParametersDescription
date_iteratorCommon base class for all day level iterators.
day_iteratordate start_date, int day_count=1Iterate day_count days at a time.
week_iteratordate start_date, int week_offset=1Iterate week_offset weeks at a time.
month_iteratordate start_date, int month_offset=1Iterate 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. +
year_iteratordate start_date, int year_offset=1Iterate year_offset years
+ + +


+ +Last modified: Wed Aug 21 16:12:55 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + + diff --git a/doc/class_gregorian_calendar.html b/doc/class_gregorian_calendar.html new file mode 100644 index 0000000..80e259c --- /dev/null +++ b/doc/class_gregorian_calendar.html @@ -0,0 +1,87 @@ + + +gregorian::gregorian_calendar Documentation + + + + + +C++ Boost + + +

gregorian::gregorian_calendar

+

 

+


+

+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Documentation +

+Header -- +Functions +

+

Introduction

+ +

+The class boost::gregorian::gregorian_calendar implements the functions +necessary to create the gregorian date system. It converts to +the year-month-day form of a date to a day number representation +and back. + +

+For most purposes this class is simply accessed by +gregorian::date and is not used directly +by the user. However, there are useful functions that +might be of use such as the end_of_month_day +function. +

+The print month example demonstrates this. +

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+

+ + +

Functions

+ + +

+ + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
static short day_of_week(ymd_type)Return the day of the week (0==Sunday, 1==Monday, etc)See also gregorian::date day_of_week
static date_int_type day_number(ymd_type) Convert a ymd_type into a day number. The day number is an absolute number of days since the epoch start.
static short end_of_month_day(year_type, month_type)Given a year and month determine the last day of the month.
static ymd_type from_day_number(date_int_type) Convert a day number to a ymd struct.
static bool is_leap_year(year_type)Returns true if specified year is a leap year.gregorian_calendar::is_leap_year(2000) --> true
+ +

+ +


+
+ +Last modified: Wed Aug 21 15:17:40 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_ptime.html b/doc/class_ptime.html new file mode 100644 index 0000000..c31cae1 --- /dev/null +++ b/doc/class_ptime.html @@ -0,0 +1,188 @@ + + +posix_time::ptime Documentation + + + + + +C++ Boost + + +

posix_time::ptime Documentation

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+ptime Documentation +

+Header -- +Construction -- +Construct from String -- +Construct from Clock -- +Accessors -- +Conversion To String -- +Operators +

+

Introduction

+ +

+The class boost::posix_time::ptime is the primary interface for time +point manipulation. In general, the ptime class is immutable once +constructed although it does allow assignment. + +

+Class ptime is dependent on gregorian::date +for the interface to the date portion of a time point. +

+Other techniques for creating times include time iterators. + + +

+ + +

+

Header

+
+#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
+
+

+

Construction

+ +

+ + + + + + + + + +
SyntaxDescriptionExample
ptime(date,time_duration)Construct from a date and offset + ptime t1(date(2002,Jan,10), time_duration(1,2,3));
+ ptime t2(date(2002,Jan,10), hours(1)+nanosec(5));
ptime(ptime)Copy constructorptime t3(t1)
+ +

+

Construction From String

+

+ + + + + +
SyntaxDescriptionExample
ptime time_from_string(const std::string&)From delimited string.std::string ts("2002-01-20 23:59:59.000"); +
+ date d(time_from_string(ts))
+

+ +

Construction From Clock

+ +

+ + + + + + + + +
SyntaxDescriptionExample
static ptime second_clock::local_time();Get the local time, second level resolution, based on the time zone settings of the computer.ptime t(second_clock::local_time())
static ptime second_clock::universal_time()Get the UTC time.ptime t(second_clock::universal_day())
+ +

+ +

Accessors

+ + +

+ + + + + + + + +
SyntaxDescriptionExample
date date() constGet the date part of a time.date d(2002,Jan,10);
+ ptime t(d, hour(1));
+ t.date() --> 2002-Jan-10;
time_duration time_of_day() constGet the time offset in the day.date d(2002,Jan,10);
+ ptime t(d, hour(1));
+ t.time_of_day() --> 01:00:00;
+ +

+

Conversion To String

+ +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
std::string to_simple_string(ptime)To YYYY-mmm-DD HH:MM:SS.fffffffff string where mmm 3 char month name. Fractional seconds only included if non-zero.2002-Jan-01 10:00:01.123456789
std::string to_iso_string(ptime)Convert to form YYYYMMDDTHHMMSS,fffffffff where T is the date-time separator20020131T100001,123456789
std::string to_iso_extended_string(ptime)Convert to form YYYY-MM-DDTHH:MM:SS,fffffffff where T is the date-time separator2002-01-31T10:00:01,123456789
+

+ + +

Operators

+ + +

+ + + + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
operator>, operator< +
operator>=, operator<=
A full complement of comparison operatorst1 == t2, etc
ptime operator+(date_duration) constReturn a ptime adding a day offsetdate d(2002,Jan,1);
+ ptime t(d,minutes(5));
+ date_duration dd(1);
+ ptime t2 = t + dd;
ptime operator-(date_duration) constReturn a ptime subtracting a day offsetdate d(2002,Jan,1);
+ ptime t(d,minutes(5));
+ date_duration dd(1);
+ ptime t2 = t - dd;
ptime operator+(time_duration) constReturn a ptime adding a time durationdate d(2002,Jan,1);
+ ptime t(d,minutes(5));
+ ptime t2 = t + hours(1) + minutes(2);
ptime operator-(time_duration) constReturn a ptime subtracting a time durationdate d(2002,Jan,1);
+ ptime t(d,minutes(5));
+ ptime t2 = t - minutes(2);
time_duration operator-(ptime) constTake the difference between two times.date d(2002,Jan,1);
+ ptime t1(d,minutes(5));
+ ptime t2(d,seconds(5));
+ time_duration t3 = t2 - t1;//negative result
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:20:18 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_time_duration.html b/doc/class_time_duration.html new file mode 100644 index 0000000..b5ac94b --- /dev/null +++ b/doc/class_time_duration.html @@ -0,0 +1,199 @@ + + +posix_time::time_duration Documentation + + + + + +C++ Boost + + +

posix_time::time_duration

+

 

+


+

+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Time Duration Documentation +

+Header -- +Construction -- +Count Based Construction -- +Construct from String -- +Accessors -- +Conversion To String -- +Operators +

+

Introduction

+ +

+The class boost::posix_time::time_duration the base type reponsible for representing a length of time. A duration can be either positive or negative. +

+Several small helper classes that derive from a base time_duration, as +shown below, to adjust for different resolutions. These classes can +shorten code and make the intent clearer. + +

+inherit +

+As an example: +

+
+  using namespace boost::gregorian;
+  using namespace boost::posix_time;
+
+  time_duration td = hours(1) + seconds(10); //01:00:01
+  td = hours(1) + nanosec(5); //01:00:00.000000005
+
+ + +

+

Header

+
+#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time/posix_time_types.hpp" //no i/o just types
+
+

+ +

Construction

+ + +

+ + + + + +
SyntaxDescriptionExample
time_duration(hours,minutes,seconds,fractional_seconds)Construct ad duration from the countstime_duration td(1,2,3,9); //1 hr 2 min 3 sec 9 nanoseconds
+ +

+

Construction By Count

+ + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
hours(long)Number of hourstime_duration td = hours(3);
minutes(long)Number of minutestime_duration td = minutes(3);
seconds(long)Number of secondstime_duration td = seconds(3);
millisec(long)Number of millisectime_duration td = millisec(3);
nanosec(long)Number of nanosectime_duration td = nanosec(3);
+ + +

+ +

Construction From String

+

+ + + + + +
SyntaxDescriptionExample
time_duration duration_from_string(const std::string&)From delimited string.std::string ts("23:59:59.000"); +
+ time_duraton td(duration_from_string(ts))
+

+ +

Accessors

+ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
long hours() constGet the number of hours.time_duration td(1,2,3); td.hours() --> 1
long minutes() constGet the number of minutes normalized.time_duration td(1,2,3); td.minutes() --> 2
long seconds() constGet the number of seconds.time_duration td(1,2,3); td.hours() --> 3
long fractional_seconds() constGet the number of fractional seconds.time_duration td(1,2,3, 1000); td.fractional_seconds() --> 1000
bool is_negative() constTrue if duration is negative.time_duration td(-1,0,0); td.is_negative() --> true
time_duration invert_sign() constGenerate a new duration with the sign inverted/time_duration td(-1,0,0); td.invert_sign() --> 01:00:00
static gdtl::time_resolutions resolution()Describes the resolution capability of the time_duration class.time_duration::resolution() --> nano
boost::int64_t ticks()Return the raw count of the duration type.time_duration td(0,0,0, 1000); td.ticks() --> 1000
static time_duration unit()Return smallest possible unit of duration type (1 nanosecond).time_duration::unit() --> time_duration(0,0,0,1)
+ +

+ +

+

Conversion To String

+ +

+ + + + + + + + + +
SyntaxDescriptionExample
std::string to_simple_string(time_duration)To HH:MM:SS.fffffffff were fff is fractional seconds that are only included if non-zero.10:00:01.123456789
std::string to_iso_string(time_duration)Convert to form HHMMSS,fffffffff.100001,123456789
+

+ +

Operators

+ + +

+ + + + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
+ operator>, operator<
+ operator>=, operator<=
A full complement of comparison operatorsdd1 == dd2, etc
time_duration operator+(time_duration) constAdd durations.time_duration td1(hours(1)+minutes(2)); +
time_duration td2(seconds(10)); +
time_duration td3 = td1 + td2;
time_duration operator-(time_duration) constSubtract durations.time_duration td1(hours(1)+nanosec(2));
+ time_duration td2 = td1 - minutes(1);
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:29:45 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/class_time_period.html b/doc/class_time_period.html new file mode 100644 index 0000000..72fd5bb --- /dev/null +++ b/doc/class_time_period.html @@ -0,0 +1,179 @@ + + +posix_time::time_period Documentation + + + + + +C++ Boost + + +

posix_time::time_period

+

 

+


+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Time Period Documentation +

+Header -- +Construction -- +Accessors -- +Conversion To String -- +Operators -- +More Info +

+

Introduction

+ +

+The class boost::posix_time::time_period provides direct representation for ranges between two times. Periods provide the ability to simplify some types of caculations by simplifing the conditional logic of the program. + +

+The time periods example provides an example of using time periods. +

+

+

+

Header

+
+#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
+
+ +

+

Construction

+

+ + + + + + + + + + + +
SyntaxDescriptionExample
time_period(ptime begin, ptime last) + Create a period as [begin, last). If last is <= begin then + the period will be defined as null. + date d(2002,Jan,01);
+ ptime t(d, seconds(10)); //10 sec after midnight
+ time_period tp(t, hours(3));
time_period(ptime start, ptime end) + Create a period as [begin, begin+len). If len is <= zero then + the period will be defined as null. + date d(2002,Jan,01);
+ ptime t1(d, seconds(10)); //10 sec after midnight
+ ptime t2(d, hours(10)); //10 hours after midnight
+ time_period tp(t1, t2);
time_period(time_period rhs)Copy constructortime_period tp1(tp)
+ +

+ +

+ +

Accessors

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SyntaxDescriptionExample
ptime begin() constReturn first time of period.date d(2002,Jan,01);
+ ptime t1(d, seconds(10)); //10 sec after midnight
+ ptime t2(d, hours(10)); //10 hours after midnight
+ time_period tp(t1, t2); + tp.begin() --> 2002-Jan-01 00:00:10
ptime last() constReturn last time in the perioddate d(2002,Jan,01);
+ ptime t1(d, seconds(10)); //10 sec after midnight
+ ptime t2(d, hours(10)); //10 hours after midnight
+ time_period tp(t1, t2); + tp.last() --> 2002-Jan-01 09:59:59.999999999
ptime end() constReturn one past the last in perioddate d(2002,Jan,01);
+ ptime t1(d, seconds(10)); //10 sec after midnight
+ ptime t2(d, hours(10)); //10 hours after midnight
+ time_period tp(t1, t2); + tp.last() --> 2002-Jan-01 10:00:00
bool is_null() constTrue if period is not well formed. eg: start less than end
bool contains(ptime) constTrue if ptime is within the perioddate d(2002,Jan,01);
+ ptime t1(d, seconds(10)); //10 sec after midnight
+ ptime t2(d, hours(10)); //10 hours after midnight
+ ptime t3(d, hours(2)); //2 hours after midnight
+ time_period tp(t1, t2); + tp.contains(t3) --> true
bool contains(time_period) constTrue if period is within the periodtime_period tp1(ptime(d,hours(1)), ptime(d,hours(12)));
+ time_period tp2(ptime(d,hours(2)), ptime(d,hours(4)));
+ tp1.contains(tp2) --> true
+ tp2.contains(tp1) --> false
bool intersects(time_period) constTrue if periods overlaptime_period tp1(ptime(d,hours(1)), ptime(d,hours(12)));
+ time_period tp2(ptime(d,hours(2)), ptime(d,hours(4)));
+ tp2.intersects(tp1) --> true
time_period intersection(time_period) constCalculate the intersection of 2 periods. Null if no intersection.
time_period merge(time_period) constReturns union of two periods. Null if no intersection.
time_period shift(date_duration)Add duration to both start and end.
+

+

Conversion To String

+ +

+ + + + + + +
SyntaxDescriptionExample
std::string to_simple_string(time_period dp)To [YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff] string where mmm is 3 char month name.[2002-Jan-01 01:25:10.000000001/2002-Jan-31 01:25:10.123456789]
+

+ + +

Operators

+ + +

+ + + + + + + + + + +
SyntaxDescriptionExample
operator==, operator!=,
operator>, operator< +
A full complement of comparison operatorstp1 == tp2, etc
operator<True if tp1.end() less than tp2.begin()tp1 < tp2, etc
operator>True if tp1.begin() greater than tp2.end()tp1 > tp2, etc
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:32:17 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/date_algorithms.html b/doc/date_algorithms.html new file mode 100644 index 0000000..dc56a9f --- /dev/null +++ b/doc/date_algorithms.html @@ -0,0 +1,93 @@ + + +Date Generators / Algorithms + + + + + +C++ Boost + + +

Date Generators / Algorithms

+

 

+
+

+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Generators / Algorithms +

+Header -- +Class Overview +

+

Introduction

+

+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. +

+

  using namespace boost::gregorian; 
+  typedef boost::date_time::nth_kday_of_month<date> nkday;
+  nkday ldgen(nkday::first, Monday, Sep)); //US labor day
+  date labor_day = ldgen.get_date(2002); //Calculate labor day for 2002
+  
+

+ The print holidays example shows a detailed usage example. +

+

Header

+
+#include "boost/date_time/date_generators.hpp" 
+
+ + +

+

Class Overview

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ClassConstruction Parametersget_date ParameterDescriptionExample
first_kday_aftergreg_day_of_week day_of_weekdate start_dayCalculate something like First Sunday after Jan 1,2002first_kday_after fkaf(Monday);
date d = fkaf.get_date(date(2002,Jan,1));//2002-Jan-07
first_kday_beforegreg_day_of_week day_of_weekdate start_dayCalculate something like First Monday before Feb 1,2002first_kday_before fkbf(Monday);
date d = fkbf.get_date(date(2002,Feb,1));//2002-Jan-28
last_kday_of_monthgreg_day_of_week day_of_week
greg_month month
greg_year yearCalculate something like last Monday of Januarylast_kday_of_month lkm(Monday,Jan);
date d = lkm.get_date(2002);//2002-Jan-28
first_kday_of_monthgreg_day_of_week day_of_week
greg_month month
greg_year yearCalculate something like first Monday of Januaryfirst_kday_of_month fkm(Monday,Jan);
date d = fkm.get_date(2002);//2002-Jan-07
partial_dategreg_month month
greg_day day_of_month
greg_year yearGenerates a date by applying the year to the given month and day.partial_date pd(Jan,1);
date d = pd.get_date(2002);//2002-Jan-01
+ +

+ +


+
+ +Last modified: Wed Aug 21 15:33:43 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/date_iterators.html b/doc/date_iterators.html new file mode 100644 index 0000000..c1b0f25 --- /dev/null +++ b/doc/date_iterators.html @@ -0,0 +1,83 @@ + + +gregorian::date iterators Documentation + + + + + +C++ Boost + +

gregorian::date iterators

+

 

+
+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Date Generators / Algorithms +

+Introduction -- +Header -- +Class Overview +

+

+

+

Introduction

+ +

+Date iterators provide a standard mechanism for iteration through dates. +Date iterators are a model of +Input Iterator +and can be used to populate collections with dates and other date generation +tasks. For example, the print month example iterates through all the days in a month and prints them. +

+All of the iterators here derive from boost::gregorian::date_iterator. + +

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+

+

Class Overview

+

+ + + + + + + + + + + + + + + + + + + +
ClassConstruction ParametersDescription
date_iteratorCommon base class for all day level iterators.
day_iteratordate start_date, int day_count=1Iterate day_count days at a time.
week_iteratordate start_date, int week_offset=1Iterate week_offset weeks at a time.
month_iteratordate start_date, int month_offset=1Iterate 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. +
year_iteratordate start_date, int year_offset=1Iterate year_offset years
+ + +


+ +Last modified: Wed Aug 21 16:03:11 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + + diff --git a/doc/dates__as__strings_8cpp-example.html b/doc/dates__as__strings_8cpp-example.html new file mode 100644 index 0000000..6611366 --- /dev/null +++ b/doc/dates__as__strings_8cpp-example.html @@ -0,0 +1,73 @@ + + +Example Documentation + + + +

dates_as_strings.cpp

Various parsing and output of strings. +

+

/*
+The following is a simple example that shows conversion of dates to and 
+from a std::string.
+
+Expected output:
+2001-Oct-09
+2001-10-09
+Tuesday October 9, 2001
+An expected exception is next: 
+  Exception: Month number is out of range 1..12
+
+*/
+
+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include "boost/gdtl/date_parsing.hpp"
+#include <iostream>
+#include <string>
+ 
+
+
+int
+main() 
+{
+
+  using namespace gregorian;
+
+  try {
+    // The following date is in ISO 8601 extended format (CCYY-MM-DD)
+    std::string s("2001-10-9"); //2001-October-05
+    date d(gdtl::parse_date<date>(s));
+    std::cout << to_simple_string(d) << std::endl;
+    
+    //Read ISO Standard(CCYYMMDD) and output ISO Extended
+    std::string ud("20011009"); //2001-Oct-09
+    date d1(gdtl::parse_undelimited_date<date>(ud));
+    std::cout << to_iso_extended_string(d1) << std::endl;
+    
+    //Output the parts of the date - Tuesday October 9, 2001
+    date::ymd_type ymd = d1.year_month_day();
+    greg_weekday wd = d1.day_of_week();
+    std::cout << wd.as_long_string() << " "
+           << ymd.month.as_long_string() << " "
+           << ymd.day << ", " << ymd.year
+           << std::endl;
+
+
+    //Let's send in month 25 by accident and create an exception
+    std::string bad_date("20012509"); //2001-??-09
+    std::cout << "An expected exception is next: " << std::endl;
+    date wont_construct(gdtl::parse_undelimited_date<date>(bad_date));
+    //use wont_construct so compiler doesn't complain, but you wont get here!
+    std::cout << "oh oh, you should reach this line: " 
+           << to_iso_string(wont_construct) << std::endl;
+  }
+  catch(std::exception& e) {
+    std::cout << "  Exception: " <<  e.what() << std::endl;
+  }
+
+
+  return 0;
+}
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/days__alive_8cpp-example.html b/doc/days__alive_8cpp-example.html new file mode 100644 index 0000000..2d94089 --- /dev/null +++ b/doc/days__alive_8cpp-example.html @@ -0,0 +1,48 @@ + + +Example Documentation + + + +

days_alive.cpp

Calculate the number of days you have been living using durations and dates. +

+

+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include "boost/gdtl/date_parsing.hpp"
+#include <iostream>
+
+int
+main() 
+{
+  
+  using namespace gregorian;
+  std::string s;
+  std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): ";
+  std::cin >> s;
+  try {
+    date birthday(gdtl::parse_date<date>(s));
+    //date birthday(2002,Jan,1);
+    date today = day_clock::local_day();
+    date_duration days_alive = today - birthday;
+    date_duration one_day(1);
+    if (days_alive == one_day) {
+      std::cout << "Born yesterday, very funny" << std::endl;
+    }
+    else if (days_alive < date_duration(0)) {
+      std::cout << "Not born yet, hmm: " << days_alive.days() 
+          << " days" <<std::endl;
+    }
+    else {
+      std::cout << "Days alive: " << days_alive.days() << std::endl;
+    }
+
+  }
+  catch(...) {
+    std::cout << "Bad date entered: " << s << std::endl;
+  }
+  return 0;
+};
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/days__till__new__year_8cpp-example.html b/doc/days__till__new__year_8cpp-example.html new file mode 100644 index 0000000..55606f9 --- /dev/null +++ b/doc/days__till__new__year_8cpp-example.html @@ -0,0 +1,31 @@ + + +Example Documentation + + + + +

days_till_new_year.cpp

Calculate the number of days till new years +

+

// This example displays the amount of time until new year's in days
+
+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include <iostream>
+
+int
+main() 
+{
+  
+  using namespace 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;
+};
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/doxygen.css b/doc/doxygen.css new file mode 100644 index 0000000..6309a8c --- /dev/null +++ b/doc/doxygen.css @@ -0,0 +1,26 @@ +H1 { text-align: center; color: lightcoral; } +H2 { margin-top: 0; margin-bottom: 0; color: slateblue; } +.bold { font-weight: bold; } +.el { text-decoration: none; font-weight: bold; color: lightslateblue } +.func { text-decoration: none; font-weight: bold; color: lightslateblue } +A.qindex { color: seagreen } +A.qindexRef {} +A.el { text-decoration: none; font-weight: bold; color: lightslateblue } +A.elRef { font-weight: bold; color: red} +A.code { text-decoration: none; font-weight: normal; color: darkblue; } +A.codeRef { font-weight: normal; } +DL.el { margin-left: -1cm } +DIV.fragment { width: 100%; border: none; background-color: #eeeeee; } +DIV.ah { background-color: black; margin-bottom: 3; margin-top: 3 } +/*TD.md { background-color: #f2f2ff }*/ +/* md == member documentation */ +TD.md { background-color: lightblue; } +DIV.groupHeader { margin-left: 16; margin-top: 12; margin-bottom: 6; font-weight: bold } +DIV.groupText { margin-left: 16; font-style: italic; font-size: smaller } +FONT.keyword { color: green } +FONT.keywordtype { color: green } +FONT.keywordflow { color: darkviolet } +FONT.comment { color: slateblue } +FONT.preprocessor { color: #806020 } +FONT.stringliteral { color: #002080 } +FONT.charliteral { color: #008080 } diff --git a/doc/gregorian.html b/doc/gregorian.html new file mode 100644 index 0000000..7ecf12e --- /dev/null +++ b/doc/gregorian.html @@ -0,0 +1,78 @@ + + +Gregorian Date System Documentation + + + + + +C++ Boost + +

+

Gregorian Date System Documentation

+

 

+


+ +

+

+Overall Index +

+Introduction -- +Usage Examples

+Temporal Types +

+Class date -- +Class date_duration -- +Class date_period +

+Other Topics +

+Date Iterators -- +Date Generators / Algorithms -- +Class gregorian_calendar -- +Class day_clock +

+

Introduction

+ +

+The gregorian date system provides a date programming system based on the Gregorian Calendar. The current implementation supports dates in the range 1400-Jan-01 to 10000-Jan-01. The implemented calendar is a "propleptic Gregorian calendar" thus extending dates back prior to it's first adoption in in 1582. + +

+Caution is required when handling historic dates as there are many adjustments required to account for the local adoption of various calendar systems. +See Calendrical Calculations by Reingold & Dershowitz for more details. The current historical range of the calendar is not limited by algorithm, but rather time to write and perform tests to ensure correctness. It is expected that the range of this calendar system will continue to increase in the future. +

+Date information from Calendrical Calculations has been used to cross-test the correctness of the Gregorian calendar implementation. +

+All types for the gregorian system are found in namespace boost::gregorian. The library supports a convience header boost/date_time/gregorian/gregorian_types.hpp that will include all the classes of the library with no input/output depedency. +Another header boost/date_time/gregorian/gregorian.hpp will include the types and the input/output code. +

+The class boost::gregorian::date is the primary +temporal type for users. + +If you are interested in learning about writing programs do specialized date calculations such as finding the "first sunday in april" see the date generators and algorithms page. + + +

+

Usage Examples

+ +

+ + + + + +
ExampleDescription
Days Alive Days Till New YearSimple date arithmetic. Retrieve current day from clock.
Dates as stringsSimple parsing and formmatting of dates from/to strings
Date Period CalculationsSee if a date is in a set of date periods (eg: is it a holiday/weekend)
Print a monthSmall utility program which prints out all the days in a month from command line. Need to know if 1999-Jan-1 was a Friday or a Saturday? This program shows how to do it.
Print HolidaysUses date generators to convert abstract specification into concrete set of dates.
+ +

+ +


+
+ +Last modified: Wed Aug 21 15:43:34 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..efa7052 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,219 @@ + + +Boost Date-Time Library Documentation + + + + + +C++ Boost + + +

Boost Date-Time Library Documentation

+

+

Version 1.00

+
+ +

Contents

+

+Overview

+ +

+Introduction -- +Motivation -- +Usage Examples -- +Domain Concepts -- +Tests -- +Design and Extensions -- +Acknowledgements -- +More Info +

+Build-Compiler Information + +

+Date Programming

+Gregorian Date System
+

+ +

+Time Programming

+Posix Time System
+ +

+ + + +

Introduction

+ +

+A set of date-time libraries based on generic programming concepts. +

+

Motivation

+ +

+The motivation for this library comes from working with and helping build several date-time libraries on several projects. Date-time libraries provide fundamental infrastructure for most development projects. However, most of them have limitations in their ability to calculate, format, convert, or perform some other functionality. For example, most libraries do not correctly handle leap seconds, provide concepts such as infinity, or provide the ability to use high resolution or network time sources. These libraries also tend to be rigid in their representation of dates and times. Thus customized policies for a project or subproject are not possible. +

+Programming with dates and times should be almost as simple and natural as programming with strings and integers. Applications with lots of temporal logic can be radically simplified by having a robust set of operators and calculation capabilities. Classes should provide the ability to compare dates and times, add lengths or time durations, retrieve dates and times from clocks, and work naturally with date and time intervals. +

+

Usage Examples

+ +

+The following shows examples of the sorts of code that can be written using the gregorian date system. See Date Programming for more details. +

+

     using namespace boost::gregorian; 
+     date weekstart(2002,Feb,1);
+     date weekend  (2002,Feb,7);
+     date_duration fiveDays(5); 
+     date d3 = d1 + fiveDays;
+     date today = day_clock::local_day();
+     if (d3 >= today) {} //date comparison operators
+     
+     date_period thisWeek(d1,d2);
+     if (thisWeek.contains(today)) {}//do something
+    
+     //iterate and print the week
+     day_iterator itr(weekstart);
+     for (; itr <= weekend; ++itr) {
+       std::cout << to_iso_extended_string(*itr) << std::endl;
+     }     
+ +And some time examples using the posix_time system. See Time Programming for more details. + +
     using namespace boost::posix_time; 
+     date d(2002,Feb,1); //an arbitrary date
+     ptime t1(d, hours(5)+nanosec(100));//date + time of day offset
+     ptime t2 = t1 - minutes(4)+seconds(2);
+     ptime now = second_clock::local_time(); //use the clock
+     //Get the date part out of the time
+     date today = now.date();
+     date tommorrow = today + date_duration(1);
+     ptime tommorrow_start(tommorrow); //midnight 
+
+     //starting at current time iterator adds by one hour
+     time_iterator titr(now,hours(1)); 
+     for (; titr < tommorrow_start; ++titr) {
+       std::cout << to_simple_string(*titr) << std::endl;
+     }
+

+ +

+

Domain Concepts

+

+The date time domain is rich in terminology and problems. The following is a brief introduction to the concepts you will find reflected in the library. +

+ +The library supports 3 basic temporal types: +

+ +Each of these temporal types has a Resolution which is defined by the smallest representable duration. A Time system provides all these categories of temporal types as well as the rules for labeling and calculating with time points. Calendar Systems are simply time systems with a maximum resolution of one day. The Gregorian system is the most widely used calendar system today (the ISO system is basically a derivative of this). However, there are many other calendar systems as well. UTC (Coordinated Universal Time) is a widely used civil time system. UTC is adjusted for earth rotation at longitude 0 by the use of leap seconds (This is not predictable, only as necessary). Most local time systems are based on UTC but are also adjusted for earth rotation so that daylight hours are similar everywhere. In addition, some local times include daylight savings time (DST) adjustments to provide additional daylight during the summer. + +

+A Clock Device is software component (tied to some hardware) that provides the current date or time with respect to a time system. + +

+The library provides support for calculating with dates and times. However, time calculations are not quite the same as calculating with integers. If you are serious about the accuracy of your time calculations need to read about Stability, Predictability, and Approximations. +

+Additional reference materials can be found in the following: + +

+ +

+ +

+

Tests

+ +

+The library provides a large number of tests in the +

+   libs/date_time/test 
+   libs/date_time/test/gregorian
+   libs/date_time/test/posix_time
+
+

+directories. Building and executing these tests assures that the installation is correct and that the library is functioning correctly. In addition, these tests facilitate the porting to new compilers. Finally, the tests provide examples of many functions not explicitly described in the usage examples. +

+ +

Design and Extensions

+

+A large part of the genesis of this library has been the observation that +few date-time libraries are built in a fashion that allows customization +and extension. A typical example, the calendar logic is built directly +into the date class. Or the clock retrieval functions are built directly +into the time class. These design decisions usually make it impossible to +extend or change the library behavior. At a more fundamental level, +there are usually assumptions about the resolution of time representation +or the gregorian calendar. +

+Often times, the result is that a project must settle for a less +than complete library because of a requirement for high resolution +time representation or other assumptions that do not match the +implementation of the library. This is extremely unfortunate because +development of a library of this sort is far from a trivial task. +

+While the design is far from perfect the current design is far +more flexible than any date-time library the author is aware of. It +is expected that the various aspects of extensibility will be better +documented in future versions. Information about the design goals +of the library is summarized here. +

+ +

Acknowledgements

+ +

+Many people have contributed to the development of this library. +In particular Hugo Duncan and Joel de Guzman for help with porting to +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 +to boost reviewers and users including: +William Seymour, Kjell Elster, Beman Dawes, Gary Powell, +Andrew Maclean, William Kempf, Peter Dimov, Chris Little, +David Moore, Darin Adler, Gennadiy Rozental, Joachim Achtzehnter, +Paul Bristow, Jan Langer, Mark Rodgers, Glen Knowles, Matthew Denman, +and George Heintzelman. + +

+

More Info

+ +

+The design of the library is currently being evolved using Wiki and email discussions. You can find more information at: +

+

+ +
+
+ +Last modified: Wed Aug 21 15:04:19 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/local__utc__conversion_8cpp-example.html b/doc/local__utc__conversion_8cpp-example.html new file mode 100644 index 0000000..202177d --- /dev/null +++ b/doc/local__utc__conversion_8cpp-example.html @@ -0,0 +1,98 @@ + + +Example Documentation + + + +

local_utc_conversion.cpp

Demonstrate utc to local and local to utc calculations including dst. +

+

//Demonstrate conversions between a local time and utc
+/* Output:
+
+UTC <--> New York while DST is NOT active (5 hours)
+2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time 
+2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time 
+
+UTC <--> New York while DST is active (4 hours)
+2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time 
+2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time 
+
+UTC <--> Arizona (7 hours)
+2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time 
+
+*/
+
+
+
+#include "boost/gdtl/posix_time/posix_time.hpp"
+#include "boost/gdtl/local_time_adjustor.hpp"
+#include "boost/gdtl/c_local_time_adjustor.hpp"
+#include <iostream>
+
+int
+main() 
+{
+  using namespace boost::posix_time;
+  using namespace boost::gregorian;
+
+  //This local adjustor depends on the machine TZ settings-- highly dangerous!
+  typedef gdtl::c_local_adjustor<ptime> local_adj;
+  ptime t10(date(2002,Jan,1), hours(7)); 
+  ptime t11 = local_adj::utc_to_local(t10);
+  std::cout << "UTC <--> Zone base on TZ setting" << std::endl;
+  std::cout << to_simple_string(t11) << " in your TZ is " 
+         << to_simple_string(t10) << " UTC time "
+         << std::endl;
+  time_duration td = t11 - t10;
+  std::cout << "A difference of: " 
+         << to_simple_string(td) << std::endl;
+
+
+  //eastern timezone is utc-5
+  typedef gdtl::local_adjustor<ptime, -5, us_dst> us_eastern;
+
+  ptime t1(date(2001,Dec,31), hours(19)); //5 hours b/f midnight NY time
+
+  std::cout << "\nUTC <--> New York while DST is NOT active (5 hours)" 
+         << std::endl;
+  ptime t2 =  us_eastern::local_to_utc(t1);
+  std::cout << to_simple_string(t1) << " in New York is " 
+         << to_simple_string(t2) << " UTC time "
+         << std::endl;
+
+  ptime t3 = us_eastern::utc_to_local(t2);//back should be the same
+  std::cout << to_simple_string(t2) << " UTC is " 
+         << to_simple_string(t3) << " New York time "
+         << "\n\n";
+
+  ptime t4(date(2002,May,31), hours(20)); //4 hours b/f midnight NY time
+  std::cout << "UTC <--> New York while DST is active (4 hours)" << std::endl;
+  ptime t5 = us_eastern::local_to_utc(t4);
+  std::cout << to_simple_string(t4) << " in New York is " 
+         << to_simple_string(t5) << " UTC time "
+         << std::endl;
+
+  ptime t6 = us_eastern::utc_to_local(t5);//back should be the same
+  std::cout << to_simple_string(t5) << " UTC is " 
+         << to_simple_string(t6) << " New York time "
+         << "\n" << std::endl;
+
+    
+  //Arizona timezone is utc-7 with no dst
+  typedef gdtl::local_adjustor<ptime, -7, no_dst> us_arizona;
+
+  ptime t7(date(2002,May,31), hours(17)); 
+  std::cout << "UTC <--> Arizona (7 hours)" << std::endl;
+  ptime t8 = us_arizona::local_to_utc(t7);
+  std::cout << to_simple_string(t7) << " in Arizona is " 
+         << to_simple_string(t8) << " UTC time "
+         << std::endl;
+
+  
+  return 0;
+}
+
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/local_time_adjust.html b/doc/local_time_adjust.html new file mode 100644 index 0000000..149d9a1 --- /dev/null +++ b/doc/local_time_adjust.html @@ -0,0 +1,92 @@ + + +posix_time::local time adjust Documentation + + + + + +C++ Boost + + +

Local Time Adjustment

+

 

+


+

+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Local Time Adjustment +

+Header -- +Class Overview -- +More Info +

+

Introduction

+

+A frequent problem in time representation is the conversion between +various local time systems. In general this is accomplished by +using a reference time system. The reference time system is typically +UTC. +

+Since the posix_time system does no internal time adjustment it +can be used to represent both local times and UTC times. However, +the user is currently left to handle conversions and time zone +knowledge explicitly. +

+The library offers two different ways to perform UTC to local conversions. +The first is using the time zone settings of the computer. This is +a useful solution for converting a UTC time for a user machine. This +approach depends on the ctime API and will provide incorrect results +if the environment is set incorrectly. +The other approach allows conversion from any zone to UTC and back +independent of the settings of the time zone settings of the +computer. The local utc conversion example demonstrates both of these techniques. + +

+

Header

+
+#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
+or
+#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
+
+

+ +

Class Overview

+

+ + + + + + + + + + + + + + +
ClassDescriptionExample
date_time::c_local_adjustor<ptime>::utc_to_local(ptime)Calculate local machine time from a UTC time based on time zone settings and the C API. + typedef boost::date_time::c_local_adjustor<ptime> local_adj;
+ ptime t10(date(2002,Jan,1), hours(7));
+ ptime t11 = local_adj::utc_to_local(t10);
+
date_time::local_adjustor<ptime, utc_offset, dst_rules>::utc_to_local(ptime)Calculate local machine time from a UTC time based daylight savings rules and utc offsetexample +
date_time::local_adjustor<ptime, utc_offset, dst_rules>::local_to_utc(ptime)Calculate UTC time based on daylight savings rules and utc offset.example +
+ +

+ + +


+
+ +Last modified: Wed Aug 21 15:50:17 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/period__calc_8cpp-example.html b/doc/period__calc_8cpp-example.html new file mode 100644 index 0000000..0c638ae --- /dev/null +++ b/doc/period__calc_8cpp-example.html @@ -0,0 +1,91 @@ + + +Example Documentation + + + + +

period_calc.cpp

Calculates if a date is in an 'irregular' collection of periods using period calculation functions. +

+

/*
+This example demonstrates a simple use of periods for the calculation
+of date information.
+
+The example calculates if a given date is a weekend or holiday
+given an exclusion set.  That is, each weekend or holiday is
+entered into the set as a time interval.  Then if a given date
+is contained within any of the intervals it is considered to
+be within the exclusion set and hence is a offtime.
+
+Output:
+Number Excluded Periods: 5
+20020202/20020203
+20020209/20020210
+20020212/20020212
+20020216/20020217
+In Exclusion Period: 20020216 --> 20020216/20020217
+20020223/20020224
+
+*/
+
+
+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include <set>
+#include <algorithm>
+#include <iostream>
+
+typedef std::set<gregorian::date_period> date_period_set;
+
+//Simple population of the exclusion set
+date_period_set
+generateExclusion()
+{
+  using namespace gregorian;
+  date_period periods_array[] = 
+    { date_period(date(2002,Feb,2), date(2002,Feb,4)),//weekend of 2nd-3rd
+      date_period(date(2002,Feb,9), date(2002,Feb,11)),
+      date_period(date(2002,Feb,16), date(2002,Feb,18)),
+      date_period(date(2002,Feb,23), date(2002,Feb,25)),
+      date_period(date(2002,Feb,12), date(2002,Feb,13))//a random holiday 2-12
+    };
+  const int num_periods = sizeof(periods_array)/sizeof(date_period);
+
+  date_period_set ps;
+  //insert the periods in the set
+  std::insert_iterator<date_period_set> itr(ps, ps.begin());
+  std::copy(periods_array, periods_array+num_periods, itr );
+  return ps;
+  
+}
+
+
+int main() 
+{
+  using namespace gregorian;
+  
+  date_period_set ps = generateExclusion();
+  std::cout << "Number Excluded Periods: "  << ps.size() << std::endl;
+
+  date d(2002,Feb,16);
+  date_period_set::const_iterator i = ps.begin();
+  //print the periods, check for containment
+  for (;i != ps.end(); i++) {
+    std::cout << to_iso_string(*i) << std::endl;
+    //if date is in exclusion period then print it
+    if (i->contains(d)) {
+      std::cout << "In Exclusion Period: "
+          << to_iso_string(d) << " --> " << to_iso_string(*i)
+          << std::endl;
+    }
+  }
+
+  return 0;  
+
+}
+
+
+
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/posix_time.html b/doc/posix_time.html new file mode 100644 index 0000000..2ea3a2b --- /dev/null +++ b/doc/posix_time.html @@ -0,0 +1,57 @@ + + +Posix Time System Documentation + + + + + +C++ Boost + + +

Posix Time System Documentation

+

 

+


+

+Overall Index -- +Gregorian Index +

+Temporal Types +

+Class ptime -- +Class time_duration -- +Class time_period +

+Other Topics +

+Time Iterators -- +UTC / Local Time Adjustments + + +

+

Introduction

+

+Defines a non-adjusted time system with nano-second resolution and +stable calculation properties. This time system uses the Gregorian +calendar to implement the date portion of the time representation. + +

+

Usage Examples

+ + + + + +
ExampleDescription
Time MathA few simple calculations using ptime and time_durations.
Print HoursRetrieve time from clock, use a time_iterator.
Local to UTC ConversionDemonstrates a couple different ways to convert a local to UTC time including daylight savings rules.
Time periodsSome simple examples of intersection and display of time periods.
+ + +
+
+ +Last modified: Wed Aug 21 15:52:19 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + diff --git a/doc/print__holidays_8cpp-example.html b/doc/print__holidays_8cpp-example.html new file mode 100644 index 0000000..f5a8111 --- /dev/null +++ b/doc/print__holidays_8cpp-example.html @@ -0,0 +1,113 @@ + + +Example Documentation + + + +

print_holidays.cpp

This is an example of using functors to define a holiday schedule +

+

/*generate a set of dates using a collections of date generators
+Output looks like:
+Enter Year: 2002
+2002-Jan-01 [Tue]
+2002-Jan-21 [Mon]
+2002-Feb-12 [Tue]
+2002-Jul-04 [Thu]
+2002-Sep-02 [Mon]
+2002-Nov-28 [Thu]
+2002-Dec-25 [Wed]
+Number Holidays: 7
+*/
+
+
+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <iostream>
+#include <set>
+
+namespace std {
+  //define an operator << for date so transform can call
+  std::ostream&
+  operator<<(std::ostream& os, const gregorian::date& d)
+  {
+    os << gregorian::to_simple_string(d);
+    return os;
+  }
+
+}
+
+void
+print_date(gregorian::date d) 
+{
+  std::cout << d << " [" << d.day_of_week().as_short_string() << "]\n";
+}
+
+
+int
+main() {
+
+  std::cout << "Enter Year: ";
+  int year;
+  std::cin >> year;
+
+
+  using namespace gregorian;
+
+  //define a collection of holidays fixed by month and day
+  std::vector<partial_date> holidays;
+  holidays.push_back(partial_date(Jan,1)); //Western New Year
+  holidays.push_back(partial_date(Jul,4)); //US Independence Day
+  holidays.push_back(partial_date(Dec,25));//Christmas day
+
+
+  //define a shorthand for the nkday function object
+  typedef gdtl::nth_kday_of_month<date> nkday;
+  //define a collection of nth kday holidays
+  std::vector<nkday> more_holidays;
+  more_holidays.push_back(nkday(nkday::first,  Monday,   Sep)); //US labor day
+  more_holidays.push_back(nkday(nkday::third,  Monday,   Jan)); //MLK Day
+  more_holidays.push_back(nkday(nkday::second, Tuesday,  Feb)); //Pres day
+  more_holidays.push_back(nkday(nkday::fourth, Thursday, Nov)); //Thanksgiving
+
+  typedef std::set<date> date_set;
+  date_set all_holidays;
+  
+#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200))  // 1200 == VC++ 6.0
+  std::cout << "Sorry, this example temporarily disabled on VC 6.\n"
+         << "The std::transform isn't accepted by the compiler\n"
+         << "So if you hack up the example without std::transform\n"
+         << "it should work\n"
+         << std::endl; 
+  
+#else
+
+  //generate a set of concrete dates from the 'partial_date' holidays
+  //by calling the get_date functions
+  std::transform(holidays.begin(), holidays.end(),
+           std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
+           std::bind2nd(std::mem_fun_ref(&partial_date::get_date),
+                     year));
+
+  //Now add in the 'floating' holidays 
+  std::transform(more_holidays.begin(), more_holidays.end(),
+           std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
+           std::bind2nd(std::mem_fun_ref(&nkday::get_date),
+                     year));
+
+
+
+  //print the holidays to the screen
+  std::for_each(all_holidays.begin(), all_holidays.end(), print_date);
+  std::cout << "Number Holidays: " << all_holidays.size() << std::endl;
+
+#endif
+
+return 0;
+
+}
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/print__hours_8cpp-example.html b/doc/print__hours_8cpp-example.html new file mode 100644 index 0000000..82e9fdd --- /dev/null +++ b/doc/print__hours_8cpp-example.html @@ -0,0 +1,59 @@ + + +Example Documentation + + + +

print_hours.cpp

Demonstrate time iteration, clock retrieval, and simple calculation. +

+

//Print the remaining hours of the day
+//Uses the clock to get the local time 
+//Use an iterator to iterate over the remaining hours
+//Retrieve the date part from a time
+/* Expected Output something like:
+
+2002-Mar-08 16:30:59
+2002-Mar-08 17:30:59
+2002-Mar-08 18:30:59
+2002-Mar-08 19:30:59
+2002-Mar-08 20:30:59
+2002-Mar-08 21:30:59
+2002-Mar-08 22:30:59
+2002-Mar-08 23:30:59
+Time left till midnight: 07:29:01
+
+*/
+
+
+#include "boost/gdtl/posix_time/posix_time.hpp"
+#include <iostream>
+
+
+int
+main() 
+{
+  using namespace boost::posix_time;
+  using namespace boost::gregorian;
+
+  //get the current time from the clock -- one second resolution
+  ptime now = second_clock::local_time();
+  //Get the date part out of the time
+  date today = now.date();
+  date tommorrow = today + date_duration(1);
+  ptime tommorrow_start(tommorrow); //midnight 
+
+  //iterator adds by one hour
+  time_iterator titr(now,hours(1)); 
+  for (; titr < tommorrow_start; ++titr) {
+    std::cout <<to_simple_string(*titr) << std::endl;
+  }
+  
+  time_duration remaining = tommorrow_start - now;
+  std::cout << "Time left till midnight: " 
+         << to_simple_string(remaining) << std::endl;
+  return 0;
+}
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/print__month_8cpp-example.html b/doc/print__month_8cpp-example.html new file mode 100644 index 0000000..7f05e86 --- /dev/null +++ b/doc/print__month_8cpp-example.html @@ -0,0 +1,62 @@ + + +Example Documentation + + + +

print_month.cpp

Simple utility to print out days of the month with the days of a month. Demontstrates date iteration (gdtl::date_itr). +

+

/*
+This example prints all the dates in a month. It demonstrates
+the use of iterators as well as functions of the gregorian_calendar
+
+Output:
+Enter Year: 2002
+Enter Month(1..12): 2
+2002-Feb-01 [Fri]
+2002-Feb-02 [Sat]
+2002-Feb-03 [Sun]
+2002-Feb-04 [Mon]
+2002-Feb-05 [Tue]
+2002-Feb-06 [Wed]
+2002-Feb-07 [Thu]
+*/
+
+#include "boost/gdtl/gregorian/gregorian.hpp"
+#include <iostream>
+
+int
+main()
+{
+  std::cout << "Enter Year: ";
+  int year, month;
+  std::cin >> year;
+  std::cout << "Enter Month(1..12): ";
+  std::cin >> month;
+
+  using namespace gregorian;
+  try {
+    //Use the calendar to get the last day of the month
+    int eom_day = gregorian_calendar::end_of_month_day(year,month);
+    date endOfMonth(year,month,eom_day);
+
+    //construct an iterator starting with firt day of the month
+    day_iterator ditr(gregorian::date(year,month,1));
+    //loop thru the days and print each one
+    for (; ditr <= endOfMonth; ++ditr) {
+      std::cout << gregorian::to_simple_string(*ditr) << " ["
+          << ditr->day_of_week().as_short_string() << "]"
+          << std::endl; 
+    }
+  }
+  catch(std::exception& e) {
+
+    std::cout << "Error bad date, check your entry: \n"
+           << "  Details: " << e.what() << std::endl;
+  }
+  return 0;
+}
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/time__math_8cpp-example.html b/doc/time__math_8cpp-example.html new file mode 100644 index 0000000..ebc311c --- /dev/null +++ b/doc/time__math_8cpp-example.html @@ -0,0 +1,40 @@ + + +Example Documentation + + + +

time_math.cpp

Various types of calculations with times and time durations. +

+

//Some simple examples of constructing and calculating with times
+//Output:
+//2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000
+
+#include "boost/gdtl/posix_time/posix_time.hpp"
+#include <iostream>
+
+int
+main() 
+{
+  using namespace boost::posix_time;
+  using namespace boost::gregorian;
+
+  date d(2002,Feb,1); //an arbitrary date
+  //construct a time by adding up some durations durations
+  ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
+  //construct a new time by subtracting some times
+  ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(1);
+  //construct a duration by taking the difference between times
+  time_duration td = t2 - t1;
+    
+  std::cout << to_simple_string(t2) << " - " 
+         << to_simple_string(t1) << " = "
+         << to_simple_string(td) << std::endl;
+  
+  return 0;
+}
+
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/time__periods_8cpp-example.html b/doc/time__periods_8cpp-example.html new file mode 100644 index 0000000..bbcd029 --- /dev/null +++ b/doc/time__periods_8cpp-example.html @@ -0,0 +1,62 @@ + + +Example Documentation + + + +

time_periods.cpp

Demonstrate some simple uses of time periods. +

+

//Some simple examples of constructing and calculating with times
+//Returns:
+//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] contains 2002-Feb-01 03:00:05
+//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] intersected with
+//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] is 
+//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999]
+
+
+#include "boost/gdtl/posix_time/posix_time.hpp"
+#include <iostream>
+
+using namespace posix_time;
+using namespace gregorian;
+
+//Create a simple period class to contain all the times in a day
+class day_period : public time_period
+{
+public:
+  day_period(date d) : time_period(ptime(d),//midnight
+                       ptime(d,hours(24)))
+  {}
+
+};
+
+int
+main() 
+{
+
+  date d(2002,Feb,1); //an arbitrary date
+  //a period that represents a day  
+  day_period dp(d);
+  ptime t(d, hours(3)+seconds(5)); //an arbitray time on that day
+  if (dp.contains(t)) {
+    std::cout << to_simple_string(dp) << " contains "
+           << to_simple_string(t)  << std::endl;
+  }
+  //a period that represents part of the day
+  time_period part_of_day(ptime(d, hours(0)), t);
+  //intersect the 2 periods and print the results
+  if (part_of_day.intersects(dp)) {
+    time_period result = part_of_day.intersection(dp);
+    std::cout << to_simple_string(dp) << " intersected with\n"
+                << to_simple_string(part_of_day) << " is \n"
+           << to_simple_string(result) << std::endl;
+  }
+    
+  
+  return 0;
+}
+
+

+Generated Wed Mar 13 13:38:03 2002 by Doxygen for CrystalClear Software © 2000-2002
+ + diff --git a/doc/time_duration_inherit.png b/doc/time_duration_inherit.png new file mode 100644 index 0000000000000000000000000000000000000000..ee6237845e77026fdcede02aa1f6d3c8042b3ad9 GIT binary patch literal 2033 zcmeAS@N?(olHy`uVBq!ia0y~yV9sS=U`S_x)eQ5Fa1kB_$;(na{wG$iUFZz@WjvoXdMDyNrQ>fxX1j z*OmPe3!@m1r77#V=L`(&nVv3=Ar*7p#`@+x(Gp=qE%ULn^9@B@FWG<1G-2dnjg=2gn6yk{x4((KEkl#j^!Djze%b&1_)aW0 z^yQvaU)U|lA6#d;W6p;I#*fyDG409K*xj49HZ6BSPXpJ{+s6;^ zo$r~;W>%VfecPO`+0*2Y@dqxS&Aq$+u0~gMUMj2KWu4Ve-yaXwpLh1rk81xtSDPN? z{y2T^xTC-o`RJ8zo5DT~Gdf#bt~V?I{5Uhfwfy`-AS#t>s?lEH&U;D__o}A z&(-!vxiOW=-SbU0uiLxPq3r3~53}FAm7cJ5pXZ`^H{2DpuWkRQutSJ@Zq)sb?NuCa z)cFtoRk7A}*?2ipAUW;n<4)hdF?Db59W~xKU*+Db#MgURp3AgWtZp^Aw`*Ouz)5rd z37y-c7JNQ=o8@EKY=wJy!bfiB9(ua==dWK(U0f!r_p%QDc5cyUoojyi+Cgv5EDD`UQeaX8LE%!c#JupDP8^H6LD<0R?RHS zwAtzpr4=-@d=|y%zx<@O@|Vf$-9j8&7hX4MZaY?9Q+H2IFQz+y(@{Fp?(ZXqgXzK_ zdY)Ws*B9d)2D7+TCZ|gRV83&;yb-!R>@e?3bCbvdiiE6GR$(i zd)9H8@hTm17CXPuj>EtuN73ofv&FirPQC~bG;Gdgi}>QAk`z%gp{Z$wRC1ke-6T=P zIe$_O%kG5TF(})YFO}=_Zxe&{WxFh+od4B_tleDy3ANmn-2eJ?+5Y=`-EDrJj>&od zF#L_Q^P%sb%3D==+e7jkA&7~yHr$sKlC2fS{~$8?l~!A?rm+WX{p(J+onnNv&9wbz{_ogn7qpGh z!mZ7hDr8f`if_AxTYNlVJ!xrW;Oj^C@~^${dLHv~if(Uzu*aR; zef`t@w?8@`BXfPl8DH-^)Ak>^5j^!ZkD{Dt)80Eh`(18wDEpL7u}IQ*R>b^I=;d2h zR}QZ~<~^K8*3Gfn67DzWe22((e(#6Zy<~3*^_U#J_(=CruI{=CR(k{&uH@A9Q@iFO zv_tQifP1q#r{O-$Wt-NwTOOI1;Fo)5$CefA6R&>^YPYQK>etXo?ATP`-u7ks=9z`% zb9Wb+uiN!hAn|{$UDoI0v!(nkaxYBW=$Nv<;yTOoZnxd)bMlu6UdUT=ITp&MkaUaiu5JkV@AL3nv!#G9Y2q- z%9r^Z6`F5+Pt2Ju|2$nT|L^K4%JQdI9MGL#GHvVg#Ty(hKD^?;x9h{UCC@j0OF9v| zd&^f5PRXz9^K9l-eN0}tye>h*h5PmN1IOQ7I6v#+Zy}F4_ns$fYpvN>S$ogHDc&{o zXa2OGX4n5;|FuWA$YqU-py-cFGtbn?xGmfB_Jg5^;-)5#^R8MvTQufsvsW~)bSl}C zu_XNIb53VP@kFf;hQEs^)QTQ?8LBC&{Y9pPTVY|&L*ElIhbFQ8S@JIWYLxZlo6F;K z9{P&wi|#N?3AKEpp18PdR^jdI&7zB1Z_c0jd(YD2FHNT$@Kdzs6kb&+Z1g;QyX-v| z-DdNtxw`kR{GNY$wuWu%AC-bDN>(42#$7*J=`FUl_2&G_uahTO>{ZLxd7_@^6n^i< z7M+8QU*CR`ypi%zZPUEHnM-eeQ*)Djz-yKzIrm1E*aKdLDDKS_$*bqL9C?{~YWC_I zdstu3Ru1{R?ArE)8MTvR_MXh`IyhVA)9f`o@%QHho_=xU&8B^|B5U%Oz34U&{c$7m zK0{$uYSx8~mF3?jzjTT&wzquuUVSM~y}hRO6u%dhdv478kuUdY;nYRt-zT43EOxPT ztJ@K=4|{gc_Yq#(s(U*r@4Y(n3A^bYmU0YoWh!%~Gw`bfvGK~5y0(4@xwk80PMogx z3_YP&=H8ETtqTg4L@MQ + +posix_time::time iterators Documentation + + + + + +C++ Boost + + +

posix_time::time iterators

+

 

+


+Overall Index -- +Gregorian Index -- +Posix Time Index +

+Time Iterators +

+Introduction -- +Header -- +Class Overview + +

+

Introduction

+ +

+Time iterators provide a standard mechanism for iteration through times. Time iterators are a model of +Input Iterator and can be used to populate collections with times. The following example +iterates using a 15 minute interation interval. +

+

+
+  using namespace boost::gregorian;
+  using namespace boost::posix_time;
+  date d(2000,Jan,20);
+  ptime start(d);//2000-Jan-20 00:00:00
+  time_iterator titr(start,minutes(15)); //iterate on 15 minute intervals
+  //produces 00:00:00, 00:15:00, 00:30:00, 00:45:00
+  for (; titr < ptime(d,hour(1)); ++titr) {
+    std::cout << to_simple_string(*titr) << std::endl;
+  }
+
+

+The print hours +example iterates through the remainder of the day incrementing by an hour. + +

+

Header

+
+#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
+
+

+

Class Overview

+

+ + + + + + + +
ClassConstruction ParametersDescription
time_iteratorptime start_time, time_duration incrementIterate incrementing by the specified duration.
+ + +


+ +Last modified: Wed Aug 21 15:56:53 MST 2002 + + by Jeff Garland © 2000-2002 +
+ + + +