summaryrefslogtreecommitdiff
path: root/boost/libs/date_time
diff options
context:
space:
mode:
Diffstat (limited to 'boost/libs/date_time')
-rw-r--r--boost/libs/date_time/build/Jamfile.v234
-rw-r--r--boost/libs/date_time/src/date_time.doc72
-rw-r--r--boost/libs/date_time/src/gregorian/date_generators.cpp38
-rw-r--r--boost/libs/date_time/src/gregorian/greg_month.cpp173
-rw-r--r--boost/libs/date_time/src/gregorian/greg_names.hpp43
-rw-r--r--boost/libs/date_time/src/gregorian/greg_weekday.cpp50
-rw-r--r--boost/libs/date_time/src/gregorian/gregorian_types.cpp62
-rw-r--r--boost/libs/date_time/src/posix_time/posix_time_types.cpp35
8 files changed, 507 insertions, 0 deletions
diff --git a/boost/libs/date_time/build/Jamfile.v2 b/boost/libs/date_time/build/Jamfile.v2
new file mode 100644
index 00000000..f294c2e1
--- /dev/null
+++ b/boost/libs/date_time/build/Jamfile.v2
@@ -0,0 +1,34 @@
+# Copyright (c) 2002-2005 CrystalClear Software, Inc.
+# Use, modification and distribution is subject to the
+# Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+#
+# Boost.date_time build and test Jamfile
+#
+# Based on boost.python Jamfile
+#
+# To run all tests quietly: jam test
+#
+# Declares the following targets:
+# 1. libboost_date_time, a static link library to be linked with all
+# Boost.date_time modules
+#
+
+
+project boost/date_time
+ : requirements
+ <define>DATE_TIME_INLINE
+ <link>shared:<define>BOOST_ALL_DYN_LINK=1
+ <link>static:<define>BOOST_DATE_TIME_STATIC_LINK
+ : usage-requirements
+ <define>DATE_TIME_INLINE
+ <link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
+ : source-location ../src
+ ;
+
+# Base names of the source files for libboost_date_time
+CPP_SOURCES = greg_month greg_weekday date_generators ;
+
+lib boost_date_time : gregorian/$(CPP_SOURCES).cpp ;
+
+boost-install boost_date_time ;
diff --git a/boost/libs/date_time/src/date_time.doc b/boost/libs/date_time/src/date_time.doc
new file mode 100644
index 00000000..920fac2e
--- /dev/null
+++ b/boost/libs/date_time/src/date_time.doc
@@ -0,0 +1,72 @@
+/* Copyright (c) 2001-2004 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland
+ * $Date$
+ */
+
+
+/*! @mainpage Boost Date-Time Library Reference Documentation
+ *
+ *
+ *@section intro Introduction
+ *
+ * The Boost Date-Time Library (originally the Generic Date-Time Library or GDTL)
+ * is a set of C++ date-time libraries based on the concepts of generic programming.
+ * This is an online reference guide generated from the source code
+ * that provides a handy way to learn about the details of the
+ * library. If you are a user you should start with the
+ * <a href="../user_docs/index.html">User Documentation</a>.
+ *
+ *@section using Using This Documentation
+ *
+ * The online documentation provides extensive information about the details
+ * of the library including:
+ * - <A href="inherits.html">Class hierarchy</A>
+ * - <A href="namespaces.html">Namespace Documentation</A>
+ * - List of <A href="files.html">source files</A>
+ * - Annotated list of classes and structs
+ * <A href="annotated.html">(Compound List)</A>
+ *
+ * For example, suppose you wanted to learn more about the
+ * gregorian::greg_month class.
+ * You could alternatively browse the
+ * - <A href="classboost_1_1gregorian_1_1greg__month.html">Class documentation page</A>
+ * - Include dependencies for greg_month.hpp
+ * - Hyperlinked and colorized source files: <A href="greg__month_8hpp-source.html">[hpp file]</A> <A href="greg__month_8cpp-source.html">[cpp file]</A>
+ *
+ * The main navigation bar at the top provides that access to many
+ * different modes of naviation through the library.
+
+ *
+ */
+
+//! Overall boost namespace -- library does not put any symbols here
+namespace boost {
+
+//! Namespace for basic templates and components used to construct date-time systems
+/*!
+ This namespace encapsulates various types of templates and classes used
+ to construct coherent date-time systems including date, time, etc. These
+ components should be considered helper components to be utilized in the
+ construction of specific date-time system implementations. See namespace
+ gregorian for one such example.
+*/
+namespace date_time {}
+
+}
+/*! Namespace for the c++ standard library. Library does not define any symbols in the namespace, but uses some classes from this namespace.
+*/
+namespace std {}
+
+/*!\class std::out_of_range
+ \brief Exception class defined in c++ standard library.
+ A derivative of std::logic_error and std::exception and base class for
+ many exceptions in the library. See also:
+
+ <a href="http://docs.mandragor.org/files/Programming_languages/Cpp/libstdcpp_v3_Source_Documentation/classstd_1_1out__of__range.html">Mandragor docs for libstdcpp_v3 std::out_of_range</a>
+*/
+
+
+
diff --git a/boost/libs/date_time/src/gregorian/date_generators.cpp b/boost/libs/date_time/src/gregorian/date_generators.cpp
new file mode 100644
index 00000000..32a58c17
--- /dev/null
+++ b/boost/libs/date_time/src/gregorian/date_generators.cpp
@@ -0,0 +1,38 @@
+/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date$
+ */
+
+
+
+#ifndef BOOST_DATE_TIME_SOURCE
+#define BOOST_DATE_TIME_SOURCE
+#endif
+#include "boost/date_time/date_generators.hpp"
+
+namespace boost {
+namespace date_time {
+
+ const char* const _nth_as_str[] = {"out of range", "first", "second",
+ "third", "fourth", "fifth"};
+
+ //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
+ BOOST_DATE_TIME_DECL const char* nth_as_str(int ele)
+ {
+ if(ele >= 1 && ele <= 5) {
+ return _nth_as_str[ele];
+ }
+ else {
+ return _nth_as_str[0];
+ }
+ }
+
+} } //namespace date_time
+
+
+
+
+
diff --git a/boost/libs/date_time/src/gregorian/greg_month.cpp b/boost/libs/date_time/src/gregorian/greg_month.cpp
new file mode 100644
index 00000000..8232378c
--- /dev/null
+++ b/boost/libs/date_time/src/gregorian/greg_month.cpp
@@ -0,0 +1,173 @@
+/* Copyright (c) 2002-2005 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date$
+ */
+
+
+
+#ifndef BOOST_DATE_TIME_SOURCE
+#define BOOST_DATE_TIME_SOURCE
+#endif
+#include "boost/date_time/gregorian/greg_month.hpp"
+#include "boost/date_time/gregorian/greg_facet.hpp"
+#include "boost/date_time/date_format_simple.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
+#include "boost/date_time/gregorian/formatters_limited.hpp"
+#else
+#include "boost/date_time/gregorian/formatters.hpp"
+#endif
+#include "boost/date_time/date_parsing.hpp"
+#include "boost/date_time/gregorian/parsers.hpp"
+
+#include "greg_names.hpp"
+namespace boost {
+namespace gregorian {
+
+ /*! Returns a shared pointer to a map of Month strings & numbers.
+ * Strings are both full names and abbreviations.
+ * Ex. ("jan",1), ("february",2), etc...
+ * Note: All characters are lowercase - for case insensitivity
+ */
+ greg_month::month_map_ptr_type greg_month::get_month_map_ptr()
+ {
+ static month_map_ptr_type month_map_ptr(new greg_month::month_map_type());
+
+ if(month_map_ptr->empty()) {
+ std::string s("");
+ for(unsigned short i = 1; i <= 12; ++i) {
+ greg_month m(static_cast<month_enum>(i));
+ s = m.as_long_string();
+ s = date_time::convert_to_lower(s);
+ month_map_ptr->insert(std::make_pair(s, i));
+ s = m.as_short_string();
+ s = date_time::convert_to_lower(s);
+ month_map_ptr->insert(std::make_pair(s, i));
+ }
+ }
+ return month_map_ptr;
+ }
+
+
+ //! Returns 3 char english string for the month ex: Jan, Feb, Mar, Apr
+ const char*
+ greg_month::as_short_string() const
+ {
+ return short_month_names[value_-1];
+ }
+
+ //! Returns full name of month as string in english ex: January, February
+ const char*
+ greg_month::as_long_string() const
+ {
+ return long_month_names[value_-1];
+ }
+
+ //! Return special_value from string argument
+ /*! Return special_value from string argument. If argument is
+ * not one of the special value names (defined in names.hpp),
+ * return 'not_special' */
+ special_values special_value_from_string(const std::string& s) {
+ short i = date_time::find_match(special_value_names,
+ special_value_names,
+ date_time::NumSpecialValues,
+ s);
+ if(i >= date_time::NumSpecialValues) { // match not found
+ return not_special;
+ }
+ else {
+ return static_cast<special_values>(i);
+ }
+ }
+
+
+#ifndef BOOST_NO_STD_WSTRING
+ //! Returns 3 wchar_t english string for the month ex: Jan, Feb, Mar, Apr
+ const wchar_t*
+ greg_month::as_short_wstring() const
+ {
+ return w_short_month_names[value_-1];
+ }
+
+ //! Returns full name of month as wchar_t string in english ex: January, February
+ const wchar_t*
+ greg_month::as_long_wstring() const
+ {
+ return w_long_month_names[value_-1];
+ }
+#endif // BOOST_NO_STD_WSTRING
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+ /*! creates an all_date_names_put object with the correct set of names.
+ * This function is only called in the event of an exception where
+ * the imbued locale containing the needed facet is for some reason
+ * unreachable.
+ */
+ BOOST_DATE_TIME_DECL
+ boost::date_time::all_date_names_put<greg_facet_config, char>*
+ create_facet_def(char /*type*/)
+ {
+ typedef
+ boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
+
+ return new facet_def(short_month_names,
+ long_month_names,
+ special_value_names,
+ short_weekday_names,
+ long_weekday_names);
+ }
+
+ //! generates a locale with the set of gregorian name-strings of type char*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char /*type*/){
+ typedef boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
+ return std::locale(loc, new facet_def(short_month_names,
+ long_month_names,
+ special_value_names,
+ short_weekday_names,
+ long_weekday_names)
+ );
+ }
+
+#ifndef BOOST_NO_STD_WSTRING
+ /*! creates an all_date_names_put object with the correct set of names.
+ * This function is only called in the event of an exception where
+ * the imbued locale containing the needed facet is for some reason
+ * unreachable.
+ */
+ BOOST_DATE_TIME_DECL
+ boost::date_time::all_date_names_put<greg_facet_config, wchar_t>*
+ create_facet_def(wchar_t /*type*/)
+ {
+ typedef
+ boost::date_time::all_date_names_put<greg_facet_config,wchar_t> facet_def;
+
+ return new facet_def(w_short_month_names,
+ w_long_month_names,
+ w_special_value_names,
+ w_short_weekday_names,
+ w_long_weekday_names);
+ }
+
+ //! generates a locale with the set of gregorian name-strings of type wchar_t*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t /*type*/){
+ typedef boost::date_time::all_date_names_put<greg_facet_config, wchar_t> facet_def;
+ return std::locale(loc, new facet_def(w_short_month_names,
+ w_long_month_names,
+ w_special_value_names,
+ w_short_weekday_names,
+ w_long_weekday_names)
+ );
+ }
+#endif // BOOST_NO_STD_WSTRING
+#endif // BOOST_DATE_TIME_NO_LOCALE
+
+} } //namespace gregorian
+
+
+
+
+
+
diff --git a/boost/libs/date_time/src/gregorian/greg_names.hpp b/boost/libs/date_time/src/gregorian/greg_names.hpp
new file mode 100644
index 00000000..f20b320d
--- /dev/null
+++ b/boost/libs/date_time/src/gregorian/greg_names.hpp
@@ -0,0 +1,43 @@
+/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date$
+ */
+
+
+
+#ifndef DATE_TIME_SRC_GREG_NAMES_HPP___
+#define DATE_TIME_SRC_GREG_NAMES_HPP___
+
+#include "boost/date_time/gregorian/greg_month.hpp"
+#include "boost/date_time/special_defs.hpp"
+namespace boost {
+namespace gregorian {
+
+
+ const char* const short_month_names[NumMonths]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", "NAM"};
+ const char* const long_month_names[NumMonths]={"January","February","March","April","May","June","July","August","September","October","November","December","NotAMonth"};
+ const char* const special_value_names[date_time::NumSpecialValues]={"not-a-date-time","-infinity","+infinity","min_date_time","max_date_time","not_special"};
+
+
+ const char* const short_weekday_names[]={"Sun", "Mon", "Tue",
+ "Wed", "Thu", "Fri", "Sat"};
+ const char* const long_weekday_names[]= {"Sunday","Monday","Tuesday",
+ "Wednesday", "Thursday",
+ "Friday", "Saturday"};
+
+#ifndef BOOST_NO_STD_WSTRING
+ const wchar_t* const w_short_month_names[NumMonths]={L"Jan",L"Feb",L"Mar",L"Apr",L"May",L"Jun",L"Jul",L"Aug",L"Sep",L"Oct",L"Nov",L"Dec",L"NAM"};
+ const wchar_t* const w_long_month_names[NumMonths]={L"January",L"February",L"March",L"April",L"May",L"June",L"July",L"August",L"September",L"October",L"November",L"December",L"NotAMonth"};
+ const wchar_t* const w_special_value_names[date_time::NumSpecialValues]={L"not-a-date-time",L"-infinity",L"+infinity",L"min_date_time",L"max_date_time",L"not_special"};
+
+ const wchar_t* const w_short_weekday_names[]={L"Sun", L"Mon", L"Tue",
+ L"Wed", L"Thu", L"Fri", L"Sat"};
+ const wchar_t* const w_long_weekday_names[]= {L"Sunday",L"Monday",L"Tuesday",
+ L"Wednesday", L"Thursday",
+ L"Friday", L"Saturday"};
+#endif // BOOST_NO_STD_WSTRING
+} } // boost::gregorian
+#endif // DATE_TIME_SRC_GREG_NAMES_HPP___
diff --git a/boost/libs/date_time/src/gregorian/greg_weekday.cpp b/boost/libs/date_time/src/gregorian/greg_weekday.cpp
new file mode 100644
index 00000000..ffdc96f8
--- /dev/null
+++ b/boost/libs/date_time/src/gregorian/greg_weekday.cpp
@@ -0,0 +1,50 @@
+/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland, Bart Garst
+ * $Date$
+ */
+
+
+
+#ifndef BOOST_DATE_TIME_SOURCE
+#define BOOST_DATE_TIME_SOURCE
+#endif
+#include "boost/date_time/gregorian/greg_weekday.hpp"
+
+#include "greg_names.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ //! Return a 3 digit english string of the day of week (eg: Sun)
+ const char*
+ greg_weekday::as_short_string() const
+ {
+ return short_weekday_names[value_];
+ }
+ //! Return a point to a long english string representing day of week
+ const char*
+ greg_weekday::as_long_string() const
+ {
+ return long_weekday_names[value_];
+ }
+
+#ifndef BOOST_NO_STD_WSTRING
+ //! Return a 3 digit english wchar_t string of the day of week (eg: Sun)
+ const wchar_t*
+ greg_weekday::as_short_wstring() const
+ {
+ return w_short_weekday_names[value_];
+ }
+ //! Return a point to a long english wchar_t string representing day of week
+ const wchar_t*
+ greg_weekday::as_long_wstring() const
+ {
+ return w_long_weekday_names[value_];
+ }
+#endif // BOOST_NO_STD_WSTRING
+
+} } //namespace gregorian
+
diff --git a/boost/libs/date_time/src/gregorian/gregorian_types.cpp b/boost/libs/date_time/src/gregorian/gregorian_types.cpp
new file mode 100644
index 00000000..7dd7f22b
--- /dev/null
+++ b/boost/libs/date_time/src/gregorian/gregorian_types.cpp
@@ -0,0 +1,62 @@
+/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland
+ * $Date$
+ */
+
+
+/** @defgroup date_basics Date Basics
+ This page summarizes some of the key user types and functions needed
+ to write programs using the gregorian date system. This is not a
+ comprehensive list, but rather some key types to start exploring.
+
+
+**/
+
+/** @defgroup date_alg Date Algorithms / Generators
+ 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 final date.
+
+**/
+
+/** @defgroup date_format Date Formatting
+ The functions on these page are some of the key formatting functions
+ for dates.
+**/
+
+
+//File doesn't have a current purpose except to generate docs
+//and keep it changeable without recompiles
+/*! @example days_alive.cpp
+ Calculate the number of days you have been living using durations and dates.
+*/
+/*! @example days_till_new_year.cpp
+ Calculate the number of days till new years
+*/
+/*! @example print_month.cpp
+ Simple utility to print out days of the month with the days of a month. Demontstrates date iteration (date_time::date_itr).
+*/
+/*! @example localization.cpp
+ An example showing localized stream-based I/O.
+*/
+/*! @example dates_as_strings.cpp
+ Various parsing and output of strings (mostly supported for
+ compilers that do not support localized streams).
+*/
+/*! @example period_calc.cpp
+ Calculates if a date is in an 'irregular' collection of periods using
+ period calculation functions.
+*/
+/*! @example print_holidays.cpp
+ This is an example of using functors to define a holiday schedule
+ */
+/*! @example localization.cpp
+ Demonstrates the use of facets to localize date output for Gregorian dates.
+ */
+
+
+
diff --git a/boost/libs/date_time/src/posix_time/posix_time_types.cpp b/boost/libs/date_time/src/posix_time/posix_time_types.cpp
new file mode 100644
index 00000000..43953010
--- /dev/null
+++ b/boost/libs/date_time/src/posix_time/posix_time_types.cpp
@@ -0,0 +1,35 @@
+
+/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying
+ * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+ * Author: Jeff Garland
+ * $Date$
+ */
+
+
+//File doesn't have a current purpose except to generate docs
+//and keep it changeable without recompiles
+
+/** @defgroup time_basics Time Basics
+
+**/
+
+/** @defgroup time_format Time Formatting
+
+**/
+
+
+
+/*! @example local_utc_conversion.cpp
+ Demonstrate utc to local and local to utc calculations including dst.
+*/
+/*! @example time_periods.cpp Demonstrate some simple uses of time periods.
+*/
+/*! @example print_hours.cpp Demonstrate time iteration, clock retrieval, and simple calculation.
+ */
+/*! @example time_math.cpp Various types of calculations with times and time durations.
+ */
+
+
+