diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-04-11 18:19:17 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-04-11 19:20:07 (GMT) |
commit | 857e44c156a1dbefcb49bb5792c4384cebd8762a (patch) | |
tree | 11947fb81ad9c502627f1b2bb8f090fb8d53c107 /3rdParty/Boost/src/boost/date_time/gregorian | |
parent | 77d4eb7588e113beaa03f3347523b26adefdeb06 (diff) | |
download | swift-857e44c156a1dbefcb49bb5792c4384cebd8762a.zip swift-857e44c156a1dbefcb49bb5792c4384cebd8762a.tar.bz2 |
Updated Boost to 1.42.
Diffstat (limited to '3rdParty/Boost/src/boost/date_time/gregorian')
3 files changed, 56 insertions, 65 deletions
diff --git a/3rdParty/Boost/src/boost/date_time/gregorian/conversion.hpp b/3rdParty/Boost/src/boost/date_time/gregorian/conversion.hpp index 4428c05..f35796e 100644 --- a/3rdParty/Boost/src/boost/date_time/gregorian/conversion.hpp +++ b/3rdParty/Boost/src/boost/date_time/gregorian/conversion.hpp @@ -2,75 +2,65 @@ #define _GREGORIAN__CONVERSION_HPP___ /* Copyright (c) 2004-2005 CrystalClear Software, Inc. - * Use, modification and distribution is subject to the + * 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: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $ + * $Date: 2009-06-06 07:27:35 -0400 (Sat, 06 Jun 2009) $ */ #include <string> #include <stdexcept> #include <boost/throw_exception.hpp> -#include <boost/date_time/gregorian/gregorian_types.hpp> #include <boost/date_time/c_time.hpp> -#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO) -# 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 // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS -#else -# include <sstream> -# include <boost/date_time/gregorian/gregorian_io.hpp> -#endif // USE_DATE_TIME_PRE_1_33_FACET_IO +#include <boost/date_time/special_defs.hpp> +#include <boost/date_time/gregorian/gregorian_types.hpp> namespace boost { namespace gregorian { - //! Converts a date to a tm struct. Throws out_of_range exception if date is a special value inline - std::tm to_tm(const date& d) + std::tm to_tm(const date& d) { - if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){ - std::string s = "tm unable to handle date value of "; -#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO) - s += to_simple_string(d); -#else - std::ostringstream ss; - ss << d; - s += ss.str(); -#endif // USE_DATE_TIME_PRE_1_33_FACET_IO - boost::throw_exception(std::out_of_range(s)); + if (d.is_special()) + { + std::string s = "tm unable to handle "; + switch (d.as_special()) + { + case date_time::not_a_date_time: + s += "not-a-date-time value"; break; + case date_time::neg_infin: + s += "-infinity date value"; break; + case date_time::pos_infin: + s += "+infinity date value"; break; + default: + s += "a special date value"; break; + } + boost::throw_exception(std::out_of_range(s)); } - std::tm datetm; + + std::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone boost::gregorian::date::ymd_type ymd = d.year_month_day(); - datetm.tm_year = ymd.year-1900; - datetm.tm_mon = ymd.month-1; + datetm.tm_year = ymd.year - 1900; + datetm.tm_mon = ymd.month - 1; datetm.tm_mday = ymd.day; datetm.tm_wday = d.day_of_week(); - datetm.tm_yday = d.day_of_year()-1; - datetm.tm_hour = datetm.tm_min = datetm.tm_sec = 0; + datetm.tm_yday = d.day_of_year() - 1; datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst return datetm; } //! Converts a tm structure into a date dropping the any time values. inline - date date_from_tm(const std::tm& datetm) + date date_from_tm(const std::tm& datetm) { - return date(static_cast<unsigned short>(datetm.tm_year+1900), - static_cast<unsigned short>(datetm.tm_mon+1), + return date(static_cast<unsigned short>(datetm.tm_year+1900), + static_cast<unsigned short>(datetm.tm_mon+1), static_cast<unsigned short>(datetm.tm_mday)); } - } } //namespace boost::gregorian - - - #endif - diff --git a/3rdParty/Boost/src/boost/date_time/gregorian/greg_calendar.hpp b/3rdParty/Boost/src/boost/date_time/gregorian/greg_calendar.hpp index b8b1f5a..483ead5 100644 --- a/3rdParty/Boost/src/boost/date_time/gregorian/greg_calendar.hpp +++ b/3rdParty/Boost/src/boost/date_time/gregorian/greg_calendar.hpp @@ -2,27 +2,28 @@ #define GREGORIAN_GREGORIAN_CALENDAR_HPP__ /* Copyright (c) 2002,2003 CrystalClear Software, Inc. - * Use, modification and distribution is subject to the + * 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: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ + * Author: Jeff Garland + * $Date: 2010-01-10 14:17:23 -0500 (Sun, 10 Jan 2010) $ */ -#include "boost/date_time/gregorian/greg_weekday.hpp" -#include "boost/date_time/gregorian/greg_day_of_year.hpp" -#include "boost/date_time/gregorian_calendar.hpp" -#include "boost/date_time/gregorian/greg_ymd.hpp" -#include "boost/date_time/int_adapter.hpp" +#include <boost/cstdint.hpp> +#include <boost/date_time/gregorian/greg_weekday.hpp> +#include <boost/date_time/gregorian/greg_day_of_year.hpp> +#include <boost/date_time/gregorian_calendar.hpp> +#include <boost/date_time/gregorian/greg_ymd.hpp> +#include <boost/date_time/int_adapter.hpp> namespace boost { namespace gregorian { - + //!An internal date representation that includes infinities, not a date - typedef date_time::int_adapter<unsigned long> fancy_date_rep; + typedef date_time::int_adapter<uint32_t> fancy_date_rep; //! Gregorian calendar for this implementation, hard work in the base - class gregorian_calendar : + class gregorian_calendar : public date_time::gregorian_calendar_base<greg_year_month_day, fancy_date_rep::int_type> { public: //! Type to hold a weekday (eg: Sunday, Monday,...) @@ -34,14 +35,14 @@ namespace gregorian { //! Date rep implements the traits stuff as well typedef fancy_date_rep date_traits_type; - + private: }; } } //namespace gregorian - + #endif - + diff --git a/3rdParty/Boost/src/boost/date_time/gregorian/greg_date.hpp b/3rdParty/Boost/src/boost/date_time/gregorian/greg_date.hpp index 56d576f..ad67c0c 100644 --- a/3rdParty/Boost/src/boost/date_time/gregorian/greg_date.hpp +++ b/3rdParty/Boost/src/boost/date_time/gregorian/greg_date.hpp @@ -2,11 +2,11 @@ #define GREG_DATE_HPP___ /* Copyright (c) 2002,2003 CrystalClear Software, Inc. - * Use, modification and distribution is subject to the + * 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: 2008-11-12 14:37:53 -0500 (Wed, 12 Nov 2008) $ + * Author: Jeff Garland + * $Date: 2010-01-10 14:17:23 -0500 (Sun, 10 Jan 2010) $ */ #include <boost/throw_exception.hpp> @@ -28,10 +28,10 @@ namespace gregorian { using date_time::min_date_time; //! A date type based on gregorian_calendar - /*! This class is the primary interface for programming with + /*! This class is the primary interface for programming with greogorian dates. The is a lightweight type that can be - freely passed by value. All comparison operators are - supported. + freely passed by value. All comparison operators are + supported. \ingroup date_basics */ class date : public date_time::date<date, gregorian_calendar, date_duration> @@ -52,7 +52,7 @@ namespace gregorian { {} #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR //! Main constructor with year, month, day - date(year_type y, month_type m, day_type d) + date(year_type y, month_type m, day_type d) : date_time::date<date, gregorian_calendar, date_duration>(y, m, d) { if (gregorian_calendar::end_of_month_day(y, m) < d) { @@ -60,7 +60,7 @@ namespace gregorian { } } //! Constructor from a ymd_type structure - explicit date(const ymd_type& ymd) + explicit date(const ymd_type& ymd) : date_time::date<date, gregorian_calendar, date_duration>(ymd) {} //! Needed copy constructor @@ -99,16 +99,16 @@ namespace gregorian { return day_of_year_type(doy); } //!Return the Modified Julian Day number for the date. - long modjulian_day() const + date_int_type modjulian_day() const { ymd_type ymd = year_month_day(); - return gregorian_calendar::modjulian_day_number(ymd); + return gregorian_calendar::modjulian_day_number(ymd); } //!Return the iso 8601 week number 1..53 int week_number() const { ymd_type ymd = year_month_day(); - return gregorian_calendar::week_number(ymd); + return gregorian_calendar::week_number(ymd); } //! Return the day number from the calendar date_int_type day_number() const @@ -118,7 +118,7 @@ namespace gregorian { //! Return the last day of the current month date end_of_month() const { - ymd_type ymd = year_month_day(); + ymd_type ymd = year_month_day(); short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month); return date(ymd.year, ymd.month, eom_day); } @@ -126,7 +126,7 @@ namespace gregorian { private: }; - + } } //namespace gregorian |