Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84380 - in sandbox/chrono_date: boost/chrono/date libs/date/example libs/date/src libs/date/test libs/date/test/wrappers
From: vicente.botet_at_[hidden]
Date: 2013-05-19 19:29:50


Author: viboes
Date: 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
New Revision: 84380
URL: http://svn.boost.org/trac/boost/changeset/84380

Log:
Chrono/Date: Added again specific tags instead of a single type for tags; remove unuseful part in rel_date.cpp.
Added:
   sandbox/chrono_date/boost/chrono/date/nth_tag.hpp (contents, props changed)
Text files modified:
   sandbox/chrono_date/boost/chrono/date/date_generators.hpp | 46
   sandbox/chrono_date/boost/chrono/date/day.hpp | 20
   sandbox/chrono_date/boost/chrono/date/include.hpp | 2
   sandbox/chrono_date/boost/chrono/date/month_nth.hpp | 37 -
   sandbox/chrono_date/boost/chrono/date/month_nth_weekday.hpp | 76 +-
   sandbox/chrono_date/boost/chrono/date/nth_week.hpp | 18
   sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp | 80 ++
   sandbox/chrono_date/boost/chrono/date/relative_date.hpp | 26
   sandbox/chrono_date/boost/chrono/date/tuples.hpp | 2
   sandbox/chrono_date/libs/date/example/hello_world.cpp | 31
   sandbox/chrono_date/libs/date/src/rel_date.cpp | 1191 +++------------------------------------
   sandbox/chrono_date/libs/date/src/vars.cpp | 26
   sandbox/chrono_date/libs/date/test/Jamfile.v2 | 2
   sandbox/chrono_date/libs/date/test/wrappers/nth_week_pass.cpp | 10
   14 files changed, 310 insertions(+), 1257 deletions(-)

Modified: sandbox/chrono_date/boost/chrono/date/date_generators.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/date_generators.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/date_generators.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -19,7 +19,7 @@
 #include <boost/chrono/date/month_nth_weekday.hpp>
 #include <boost/chrono/date/month_nth.hpp>
 #include <boost/chrono/date/nth_week.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 #include <boost/chrono/date/date_io.hpp>
 
 namespace boost
@@ -114,52 +114,52 @@
       return res;
     }
 
- template <typename Date>
- BOOST_FORCEINLINE Date
- operator >(nth n, Date d)
+ //template <typename Date>
+ BOOST_FORCEINLINE ymd_date
+ operator >(day n, ymd_date d)
     {
- Date res;
+ ymd_date res;
       if (month(d)==dec)
       { // dec and jan have 31 days
- res = Date(year(d),month(d),day(n.value()));
+ res = ymd_date(year(d),month(d),n);
 
         if (res > d) return res;
- return Date(year(d),jan,day(n.value()));
+ return ymd_date(year(d),jan,n);
       }
 
       if (n.value()>28)
       { // As feb could have 29,30 and 31, we need to validate the two first dates
         if (res.set_if_valid_date(year(d),month(d),day(n.value(), no_check)) && res > d) return res;
         if (res.set_if_valid_date(year(d),month(month(d)+1),day(n.value(), no_check)) && res > d) return res;
- return Date(year(d),month(month(d)+2),day(n.value(), no_check)) ;
+ return ymd_date(year(d),month(month(d)+2),day(n.value(), no_check)) ;
       }
- // nth <= 28 is always valid, so the next is either in this month or the next one
- res = Date(year(d),month(d),day(n.value()));
+ // day <= 28 is always valid, so the next is either in this month or the next one
+ res = ymd_date(year(d),month(d),day(n.value()));
       if (res > d) return res;
- return Date(year(d),month(month(d)+1),day(n.value(), no_check));
+ return ymd_date(year(d),month(month(d)+1),day(n.value(), no_check));
     }
- template <typename Date>
- BOOST_FORCEINLINE Date
- operator >=(nth n, Date d)
+ //template <typename Date>
+ BOOST_FORCEINLINE ymd_date
+ operator >=(day n, ymd_date d)
     {
- Date res;
+ ymd_date res;
       if (month(d)==dec)
       { // dec and jan have 31 days
- res = Date(year(d),month(d),n.value());
+ res = ymd_date(year(d),month(d),n);
         if (res >= d) return res;
- return Date(year(d),jan,n.value());
+ return ymd_date(year(d),jan,n);
       }
 
       if (n.value()>28)
       { // As feb could have 29,30 and 31, we need to validate the two first dates
- if (res.set_if_valid_date(year(d),month(d),day(n.value(), no_check)) && res >= d) return res;
- if (res.set_if_valid_date(year(d),month(month(d)+1),day(n.value(), no_check)) && res >= d) return res;
- return Date(year(d),month(d)+2,n.value(), no_check) ;
+ if (res.set_if_valid_date(year(d),month(d),n) && res >= d) return res;
+ if (res.set_if_valid_date(year(d),month(month(d)+1),n) && res >= d) return res;
+ return ymd_date(year(d),month(month(d)+2),n, no_check) ;
       }
- // nth <= 28 is always valid, so the next is either in this month or the next one
- res = Date(year(d),month(d),n.value());
+ // day <= 28 is always valid, so the next is either in this month or the next one
+ res = ymd_date(year(d),month(d),n);
       if (res >= d) return res;
- return Date(year(d),month(month(d)+1),n.value(), no_check);
+ return ymd_date(year(d),month(month(d)+1),n, no_check);
     }
 
 

Modified: sandbox/chrono_date/boost/chrono/date/day.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/day.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/day.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -12,6 +12,7 @@
 #include <boost/cstdint.hpp>
 #include <boost/chrono/date/detail/bounded.hpp>
 #include <boost/chrono/date/detail/helpers.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 
 namespace boost
 {
@@ -67,6 +68,25 @@
         base_type(v, check)
       {
       }
+
+ /**
+ * @Effects Constructs an object of class day by storing y.
+ * @Postconditions <c>static_cast<rep>(*this) == v.value()</c>.
+ */
+ BOOST_FORCEINLINE BOOST_CONSTEXPR day(nth_1_5_tag v) :
+ base_type(v.value(), no_check)
+ {
+ }
+
+ /**
+ * @Effects Constructs an object of class day by storing y.
+ * @Postconditions <c>static_cast<rep>(*this) == v.value()</c>.
+ */
+ BOOST_FORCEINLINE BOOST_CONSTEXPR day(nth_6_31_tag v) :
+ base_type(v.value(), no_check)
+ {
+ }
+
       /**
        * @Effects Constructs an object of class day by storing y.
        * @Postconditions <c>static_cast<rep>(*this) == v.value()</c>.

Modified: sandbox/chrono_date/boost/chrono/date/include.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/include.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/include.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -17,7 +17,7 @@
 #include <boost/chrono/date/month_nth.hpp>
 #include <boost/chrono/date/month_nth_weekday.hpp>
 #include <boost/chrono/date/week.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 #include <boost/chrono/date/nth_week.hpp>
 #include <boost/chrono/date/nth_weekday.hpp>
 #include <boost/chrono/date/weekday.hpp>

Modified: sandbox/chrono_date/boost/chrono/date/month_nth.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/month_nth.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/month_nth.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -11,7 +11,7 @@
 
 #include <boost/cstdint.hpp>
 #include <boost/chrono/date/config.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 #include <boost/chrono/date/no_check.hpp>
 #include <boost/chrono/date/exceptions.hpp>
 #include <boost/chrono/date/detail/to_string.hpp>
@@ -29,31 +29,15 @@
     class month_nth
     {
       month m_; // :4
- nth d_; // :6
     public:
       /**
        * @Effects Constructs an object of class @c month_nth by storing @c m and @c d.
- * @Postconditions month() == m && nth() == d && is_valid().
- * @Throws: if d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
- */
- month_nth(month m, nth d, check_t)
- : m_(m),
- d_(d)
- {
- if (!(is_valid()))
- {
- throw_exception( bad_date("nth " + boost::chrono::to_string(int(d)) + "is out of range respect to month" + boost::chrono::to_string(m)) );
- }
- }
- /**
- * @Effects Constructs an object of class @c month_nth by storing @c m and @c d.
        * @Postconditions month() == m && nth() == d.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide the valid ones.
        */
- BOOST_CONSTEXPR month_nth(month m, nth d) BOOST_NOEXCEPT
- : m_(m),
- d_(d)
+ BOOST_CONSTEXPR month_nth(month m, last_tag) BOOST_NOEXCEPT
+ : m_(m)
       {
       }
       /**
@@ -64,27 +48,20 @@
       {
         return m_;
       }
- /**
- * @Return the @c nth component.
- */
- //BOOST_CONSTEXPR nth nth() const BOOST_NOEXCEPT
- BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::nth() const BOOST_NOEXCEPT
- {
- return d_;
- }
+
       /**
        * @Return if the stored value is a valid one.
        */
       bool is_valid() const BOOST_NOEXCEPT
       {
- return (m_.is_valid() && d_.is_valid() && d_<= days_in_month(1,m_));
+ return (m_.is_valid());
       }
     };
     /**
      * @Return a the @c month_nth with the associated parameters.
      * @Throws if d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
      */
- inline BOOST_CONSTEXPR month_nth operator/(chrono::month m, nth d)
+ inline BOOST_CONSTEXPR month_nth operator/(chrono::month m, last_tag d)
     BOOST_NOEXCEPT
     {
       return month_nth(m, d);
@@ -94,7 +71,7 @@
      * @Returns the @c month_nth with the associated parameters.
      * @Throws if @c d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
      */
- inline BOOST_CONSTEXPR month_nth operator/(nth d, chrono::month m)
+ inline BOOST_CONSTEXPR month_nth operator/(last_tag d, chrono::month m)
 BOOST_NOEXCEPT {
     return month_nth(m, d);
   }

Modified: sandbox/chrono_date/boost/chrono/date/month_nth_weekday.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/month_nth_weekday.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/month_nth_weekday.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -13,7 +13,7 @@
 #include <boost/cstdint.hpp>
 #include <boost/chrono/date/config.hpp>
 #include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/nth.hpp>
+//#include <boost/chrono/date/nth.hpp>
 #include <boost/chrono/date/nth_week.hpp>
 #include <boost/chrono/date/nth_weekday.hpp>
 
@@ -92,68 +92,64 @@
     }
 
     /**
- *
- * The class dom is used to specify a small integral value that indicates the nth day of the month (example: last, 1st).
- * valid from -32..31,
- * 1..31 means the nth day of the month,
- * 0 means last and
- * -30..-1 means last but -nth.
- * -32 means not_applicable
+ * The class @c month_nth_weekday is a tuple of @c month and @c nth_weekday that is useful when constructing dates.
      */
- class dom
- {
- public:
- typedef int_least8_t rep;
- static const rep not_applicable=-31;
-
- BOOST_CONSTEXPR dom(rep s) BOOST_NOEXCEPT : value_(s)
- {
- }
- BOOST_CONSTEXPR rep value() const BOOST_NOEXCEPT
- {
- return value_;
- }
- BOOST_CONSTEXPR bool is_not_applicable() const BOOST_NOEXCEPT
- {
- return value_==not_applicable;
- }
- private:
- rep value_; // :6 bits
- };
-
- class month_dom
+ class month_last_weekday
     {
       month m_; // :4
- dom d_; // :6
+ last_weekday d_; // :6
     public:
- BOOST_CONSTEXPR month_dom(month m, dom d) BOOST_NOEXCEPT
+ /**
+ * @Effects Constructs an object of class @c month_last_weekday by storing @c m and @c nwd.
+ * @Postconditions month() == m && last_weekday() == nwd.
+ * @Note This function doesn't check the parameters validity.
+ * It is up to the user to provide a valid ones.
+ */
+ BOOST_CONSTEXPR month_last_weekday(month::rep m, last_weekday d) BOOST_NOEXCEPT
       : m_(m),
       d_(d)
       {
       }
+ /**
+ * @Return the @c month component.
+ */
       //month month() const BOOST_NOEXCEPT
       BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::month() const BOOST_NOEXCEPT
       {
         return m_;
       }
- //BOOST_CONSTEXPR dom dom() const BOOST_NOEXCEPT
- BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::dom() const BOOST_NOEXCEPT
+ /**
+ * @Return the @c last_weekday component.
+ */
+ //BOOST_CONSTEXPR last_weekday last_weekday() const BOOST_NOEXCEPT
+ BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::last_weekday() const BOOST_NOEXCEPT
       {
         return d_;
       }
+ /**
+ * @Return if the stored value is a valid one.
+ */
+ BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
+ {
+ return ( m_.is_valid() && d_.is_valid() );
+ }
     };
 
- inline BOOST_CONSTEXPR month_dom operator/(month m, dom d) BOOST_NOEXCEPT
+ /**
+ * @return a @c month_last_weekday build with the given parameters.
+ */
+ inline BOOST_CONSTEXPR month_last_weekday operator/(month m, last_weekday d) BOOST_NOEXCEPT
     {
- return month_dom(m, d);
+ return month_last_weekday(m, d);
     }
- inline BOOST_CONSTEXPR month_dom operator/(dom d, month m) BOOST_NOEXCEPT
+ /**
+ * @return a @c month_last_weekday build with the given parameters.
+ */
+ inline BOOST_CONSTEXPR month_last_weekday operator/(last_weekday d, month m) BOOST_NOEXCEPT
     {
- return month_dom(m, d);
+ return month_last_weekday(m, d);
     }
 
-
-
   } // chrono
 
 } // boost

Added: sandbox/chrono_date/boost/chrono/date/nth_tag.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono_date/boost/chrono/date/nth_tag.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -0,0 +1,62 @@
+// date
+//
+// (C) Copyright Howard Hinnant
+// Copyright 2011 Vicente J. Botet Escriba
+// Use, modification and distribution are subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt).
+
+#ifndef BOOST_CHRONO_DATE_NTH_TAG_HPP
+#define BOOST_CHRONO_DATE_NTH_TAG_HPP
+
+#include <boost/chrono/date/config.hpp>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ struct last_tag {};
+ BOOST_CONSTEXPR_OR_CONST last_tag last = {};
+
+ /**
+ * nth 1..5 tag
+ */
+ struct nth_1_5_tag
+ {
+ const int value_;
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_1_5_tag(int v) BOOST_NOEXCEPT
+ : value_(v)
+ {}
+ BOOST_FORCEINLINE BOOST_CONSTEXPR int value() BOOST_NOEXCEPT {return value_;};
+ };
+ /**
+ * nth 6..31 tag
+ */
+ struct nth_6_31_tag
+ {
+ const int value_;
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_6_31_tag(int v) BOOST_NOEXCEPT
+ : value_(v)
+ {}
+ BOOST_FORCEINLINE BOOST_CONSTEXPR int value() BOOST_NOEXCEPT {return value_;};
+
+ };
+ //BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_tag, last, 0);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_1_5_tag, _1st, 1);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_1_5_tag, _2nd, 2);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_1_5_tag, _3rd, 3);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_1_5_tag, _4th, 4);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_1_5_tag, _5th, 5);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _6th, 6);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _7th, 7);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _8th, 8);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _9th, 9);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _10th, 10);
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DCL(nth_6_31_tag, _29th, 29);
+
+ } // chrono
+
+} // boost
+
+#endif // header

Modified: sandbox/chrono_date/boost/chrono/date/nth_week.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/nth_week.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/nth_week.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -12,7 +12,7 @@
 
 #include <boost/cstdint.hpp>
 #include <boost/chrono/date/detail/bounded.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 
 namespace boost
 {
@@ -25,16 +25,13 @@
 
     /**
      * The class nth_week is used to specify a small integral value that indicates the nth week of the month
- * (example: last_week, 1st_week). Its range is [1,6].
+ * (example: last_week, 1st_week). Its range is [1,5].
      */
- class nth_week : public bounded<nth_week_tag, 1, 6, int_least8_t>
+ class nth_week : public bounded<nth_week_tag, 1, 5, int_least8_t>
     {
- typedef bounded<nth_week_tag, 1, 6, int_least8_t> base_type;
+ typedef bounded<nth_week_tag, 1, 5, int_least8_t> base_type;
 
     public:
- BOOST_STATIC_CONSTEXPR rep not_applicable=7;
- BOOST_FORCEINLINE BOOST_CONSTEXPR nth_week() : base_type(not_applicable) {}
-
       /**
        * @Effects Constructs an object of class @c nth_week by storing @c s.
        * Throws: if @c s is outside of the range [1, 6], throws an exception of type bad_date.
@@ -49,14 +46,9 @@
       BOOST_FORCEINLINE BOOST_CONSTEXPR nth_week(int s) BOOST_NOEXCEPT
           : base_type(s)
       {}
- BOOST_FORCEINLINE BOOST_CONSTEXPR nth_week(nth_tag s) BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_week(nth_1_5_tag s) BOOST_NOEXCEPT
           : base_type(s.value_)
       {}
-
- BOOST_FORCEINLINE BOOST_CONSTEXPR bool is_not_applicable() const BOOST_NOEXCEPT
- {
- return value()==not_applicable;
- }
     };
 
   } // chrono

Modified: sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -11,8 +11,7 @@
 
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/config.hpp>
 #include <boost/chrono/date/nth_week.hpp>
 #include <boost/chrono/date/weekday.hpp>
 #include <boost/chrono/date/no_check.hpp>
@@ -36,7 +35,7 @@
        * @param dow the day of the year
        * @Effects Constructs a pair of nth-weekday.
        */
- BOOST_CONSTEXPR nth_weekday(nth_week n, weekday dow, check_t) BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_weekday(nth_week n, weekday dow, check_t) BOOST_NOEXCEPT
       :
       n_(n, check),
       dow_(dow, check)
@@ -51,7 +50,7 @@
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
- BOOST_CONSTEXPR nth_weekday(nth_week n, weekday dow) BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_weekday(nth_week n, weekday dow) BOOST_NOEXCEPT
       :
       n_(n),
       dow_(dow)
@@ -61,7 +60,7 @@
       /**
        * @Return if the stored value is a valid one.
        */
- BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
       {
         return (n_.is_valid() && dow_.is_valid());
       }
@@ -69,7 +68,7 @@
        * @Return The nth stored component.
        */
       //BOOST_CONSTEXPR nth_week nth_week() const BOOST_NOEXCEPT
- BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::nth_week() const BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::nth_week() const BOOST_NOEXCEPT
       {
         return n_;
       }
@@ -77,7 +76,54 @@
        * @Return The weekday stored component.
        */
       //BOOST_CONSTEXPR weekday weekday() const BOOST_NOEXCEPT
- BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::weekday() const BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::weekday() const BOOST_NOEXCEPT
+ {
+ return dow_;
+ }
+ };
+
+ class last_weekday
+ {
+ weekday dow_; // :3
+
+ public:
+ /**
+ * @param n the nth week
+ * @param dow the day of the year
+ * @Effects Constructs a pair of nth-weekday.
+ */
+ BOOST_FORCEINLINE BOOST_CONSTEXPR last_weekday(weekday dow, check_t) BOOST_NOEXCEPT
+ :
+ dow_(dow, check)
+ {
+ // No invalid condition
+ }
+ /**
+ * @param n the nth week
+ * @param dow the day of the year
+ * @param tag to state that no check is performed.
+ * @Effects Constructs a pair of nth-weekday.
+ * @Note This function doesn't check the parameters validity.
+ * It is up to the user to provide a valid ones.
+ */
+ BOOST_FORCEINLINE BOOST_CONSTEXPR last_weekday(weekday dow) BOOST_NOEXCEPT
+ :
+ dow_(dow)
+ {
+ }
+
+ /**
+ * @Return if the stored value is a valid one.
+ */
+ BOOST_FORCEINLINE BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
+ {
+ return (dow_.is_valid());
+ }
+ /**
+ * @Return The weekday stored component.
+ */
+ //BOOST_CONSTEXPR weekday weekday() const BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CHRONO_EXPLICIT BOOST_CONSTEXPR operator chrono::weekday() const BOOST_NOEXCEPT
       {
         return dow_;
       }
@@ -89,21 +135,25 @@
      * @param wd the weekday
      * @return a nth_weekday with the given parameters
      */
- inline BOOST_CONSTEXPR nth_weekday operator*(nth_week nw, weekday wd) BOOST_NOEXCEPT
+ BOOST_FORCEINLINE BOOST_CONSTEXPR nth_weekday operator*(nth_week nw, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nw, wd);
     }
+ BOOST_FORCEINLINE BOOST_CONSTEXPR last_weekday operator*(last_tag, weekday wd) BOOST_NOEXCEPT
+ {
+ return last_weekday(wd);
+ }
 
     /**
      * nth_weekday pseudo-literals.
      */
- extern const nth_weekday last_sun;
- extern const nth_weekday last_mon;
- extern const nth_weekday last_tue;
- extern const nth_weekday last_wed;
- extern const nth_weekday last_thu;
- extern const nth_weekday last_fri;
- extern const nth_weekday last_sat;
+ extern const last_weekday last_sun;
+ extern const last_weekday last_mon;
+ extern const last_weekday last_tue;
+ extern const last_weekday last_wed;
+ extern const last_weekday last_thu;
+ extern const last_weekday last_fri;
+ extern const last_weekday last_sat;
     extern const nth_weekday _1st_sun;
     extern const nth_weekday _1st_mon;
     extern const nth_weekday _1st_tue;

Modified: sandbox/chrono_date/boost/chrono/date/relative_date.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/relative_date.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/relative_date.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -18,7 +18,7 @@
 #include <boost/chrono/date/month_nth_weekday.hpp>
 #include <boost/chrono/date/month_nth.hpp>
 #include <boost/chrono/date/nth_week.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 #include <boost/chrono/date/days_date.hpp>
 #include <boost/chrono/date/ymd_date.hpp>
 #include <boost/chrono/date/ydoy_date.hpp>
@@ -77,8 +77,12 @@
       rel_date() BOOST_NOEXCEPT;
       rel_date(chrono::year, chrono::month, nth_weekday);
       rel_date(chrono::year, chrono::month, nth_weekday, check_t) BOOST_NOEXCEPT;
- rel_date(chrono::year, chrono::month, nth);
- rel_date(chrono::year, chrono::month, nth, check_t)BOOST_NOEXCEPT;
+ rel_date(chrono::year, chrono::month, last_weekday);
+ rel_date(chrono::year, chrono::month, last_weekday, check_t) BOOST_NOEXCEPT;
+ rel_date(chrono::year, chrono::month_nth);
+ rel_date(chrono::year, chrono::month_nth, check_t)BOOST_NOEXCEPT;
+ rel_date(chrono::year, chrono::month, last_tag);
+ rel_date(chrono::year, chrono::month, last_tag, check_t)BOOST_NOEXCEPT;
 #if BOOST_CHRONO_DATE_REL_DATE_IS_A_MODEL_OF_DATE
       rel_date(chrono::year, chrono::month, chrono::day); // TODO
       rel_date(chrono::year, chrono::month, chrono::day, check_t)BOOST_NOEXCEPT;// TODO
@@ -354,24 +358,36 @@
     {
       return rel_date(year(ym), month(ym), d);
     }
- inline rel_date operator/(year_month ym, nth d)
+ inline rel_date operator/(year_month ym, last_weekday d)
     {
       return rel_date(year(ym), month(ym), d);
     }
+ inline rel_date operator/(year_month ym, last_tag)
+ {
+ return rel_date(year(ym), month(ym), last);
+ }
 
     inline rel_date operator/(month_nth_weekday md, chrono::year y)
     {
       return rel_date(y, month(md), nth_weekday(md));
     }
+ inline rel_date operator/(month_last_weekday md, chrono::year y)
+ {
+ return rel_date(y, month(md), last_weekday(md));
+ }
 
     inline rel_date operator/(month_nth_weekday md, year::rep y)
     {
       return md / chrono::year(y);
     }
+ inline rel_date operator/(month_last_weekday md, year::rep y)
+ {
+ return md / chrono::year(y);
+ }
 
     inline rel_date operator/(month_nth md, chrono::year y)
     {
- return rel_date(y, month(md), nth(md));
+ return rel_date(y, month(md), last);
     }
 
     inline rel_date operator/(month_nth md, year::rep y)

Modified: sandbox/chrono_date/boost/chrono/date/tuples.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/tuples.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/tuples.hpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -17,7 +17,7 @@
 #include <boost/chrono/date/day.hpp>
 #include <boost/chrono/date/day_of_year.hpp>
 #include <boost/chrono/date/week.hpp>
-#include <boost/chrono/date/nth.hpp>
+#include <boost/chrono/date/nth_tag.hpp>
 #include <boost/chrono/date/detail/helpers.hpp>
 
 namespace boost

Modified: sandbox/chrono_date/libs/date/example/hello_world.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/example/hello_world.cpp (original)
+++ sandbox/chrono_date/libs/date/example/hello_world.cpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -22,14 +22,14 @@
     typedef boost::chrono::high_resolution_clock Clock;
     typedef boost::chrono::duration<double,boost::micro> micros;
 
- std::cout << jan/day(2)/2011 << '\n'; // 2011-01-02
- std::cout << month(1)/day(2)/2011 << '\n'; // 2011-01-02
- std::cout << date(year(2011),jan,day(2)) << '\n'; // 2011-01-02
+ std::cout << jan/_2nd/2011 << '\n'; // 2011-01-02
+ std::cout << month(1)/_2nd/2011 << '\n'; // 2011-01-02
+ std::cout << date(year(2011),jan,_2nd) << '\n'; // 2011-01-02
     std::cout << '\n';
 
- std::cout << jan/day(1)/2011 << '\n'; // 2011-01-02
- std::cout << jan/day(2)/2011 << '\n'; // 2011-01-02
- std::cout << feb/day(1)/2011 << '\n'; // 2011-01-02
+ std::cout << jan/_1st/2011 << '\n'; // 2011-01-02
+ std::cout << jan/_2nd/2011 << '\n'; // 2011-01-02
+ std::cout << feb/_1st/2011 << '\n'; // 2011-01-02
 
     // Print Feb. 28 for each year in the decade
     for (ymd_date d = feb/day(28)/2010, e = feb/day(28)/2020; d <= e; d += years(1))
@@ -52,7 +52,7 @@
 
     {
     // How many days between may/1/2011 and jan/1/2011?
- std::cout <<"How many days between may/1/2011 and jan/1/2011? "<< days_date(may/day(01)/2011) - jan/day(01)/2011 << '\n'; // x == 120
+ std::cout <<"How many days between may/1/2011 and jan/1/2011? "<< days_date(may/_1st/2011) - jan/_1st/2011 << '\n'; // x == 120
 
     std::cout << '\n';
     }
@@ -71,7 +71,7 @@
     date dt = aug/day(16)/2011;
     // ...
     // Create date with the same month and year but on the 5th
- date dt2 = year_month(dt)/day(5, no_check); // aug/5/2011
+ date dt2 = year_month(dt)/_5th; // aug/5/2011
     (void)dt2;
     int d = day(dt); // d == 5
     int m = month(dt); // m == 8
@@ -134,7 +134,7 @@
 
     {
 // int num_fri_in_may = (_fri[last]/may/2011).day() > 28 ? 5 : 4; // 4
- int num_fri_in_may = day(last*fri/may/2011) > 28 ? 5 : 4; // 4
+ int num_fri_in_may = (day(_1st*fri/may/2011) > 28) ? 5 : 4; // 4
       std::cout <<"Number of fridays in May"<< num_fri_in_may << '\n';
 
 // date d1 = rel_weekday(5)[_1st]/may/2011;
@@ -160,9 +160,9 @@
 // }
 
     {
- rel_date d1 = jan/_2nd/2011; // jan/2/2011
- rel_date d2 = year(2011)/jan/_2nd; // jan/2/2011
- rel_date d3 = _2nd/jan/2011; // jan/2/2011
+ ymd_date d1 = jan/_2nd/2011; // jan/2/2011
+ ymd_date d2 = year(2011)/jan/_2nd; // jan/2/2011
+ ymd_date d3 = _2nd/jan/2011; // jan/2/2011
 
       std::cout << d1 << '\n';
       std::cout << d2 << '\n';
@@ -187,7 +187,7 @@
       for (rel_date d = last/jan/2011, e = last/dec/2011; d <= e; d += months(1))
       {
           if (day(d) >= 29)
- std::cout << year(d)/month(d)/day(29,no_check) << '\n';
+ std::cout << year(d)/month(d)/_29th << '\n';
       }
     }
     {
@@ -221,10 +221,9 @@
       std::cout << dt2 << '\n';
     }
     {
- ymd_date ISO_week_start(mon <= jan/day(4)/2012);
+ ymd_date ISO_week_start(mon <= jan/_4th/2012);
       std::cout << "ISO_week_start " << ISO_week_start << '\n';
     }
-
     {
       // How many weeks until Christmas?
       days_date dt = dec/day(25)/2011;
@@ -244,7 +243,7 @@
     {
       std::cout << __FILE__<<"["<<__LINE__ <<"] "<< "How many days until next 28th?" << '\n';
       // How many days until next 28th?
- days d=days_date(nth(5)>date::today()) - date::today();
+ days d=days_date(_5th>date::today()) - date::today();
       std::cout << d << '\n';
     }
     {

Modified: sandbox/chrono_date/libs/date/src/rel_date.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/src/rel_date.cpp (original)
+++ sandbox/chrono_date/libs/date/src/rel_date.cpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -23,88 +23,37 @@
   namespace chrono
   {
 
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date()
- BOOST_NOEXCEPT
- : x_(11979588),
- y_(0),
- m_(1),
- leap_(1),
- dow_(weekday::not_applicable),
- d_(1),
- n_(nth_week::not_applicable)
- {
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date()
- BOOST_NOEXCEPT
- : x_(11979588),
- n_(nth_week::not_applicable),
- dow_(weekday::not_applicable)
- {
+ namespace detail {
+ struct weekday
+ {
+ BOOST_STATIC_CONSTEXPR int not_applicable=7;
+ };
+ struct nth_week
+ {
+ BOOST_STATIC_CONSTEXPR int not_applicable=7;
+ };
     }
 
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     rel_date::rel_date() BOOST_NOEXCEPT
     : y_(0),
     m_(1),
     leap_(1),
- dow_(weekday::not_applicable),
+ dow_(detail::weekday::not_applicable),
     d_(1),
- n_(nth_week::not_applicable)
+ n_(detail::nth_week::not_applicable)
     {
     }
 
-#endif
 #if BOOST_CHRONO_DATE_REL_DATE_IS_A_MODEL_OF_DATE
 
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(chrono::year y, chrono::month m, day d)
- :
- y_(y),
- m_(m),
- leap_(is_leap(y)),
- dow_(weekday::not_applicable),
- d_(d),
- n_(nth_week::not_applicable)
- {
- const day_of_year::rep* year_data = days_in_year_before(leap_);
- if (!(d <= year_data[m] - year_data[m - 1]))
- {
- return throw bad_date("");
- }
- year::rep by = y.value() + 32799;
- x_ = days_before_year(by) + year_data[m - 1] + d;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(chrono::year y, chrono::month m, day d)
- {
- bool leap = is_leap(y);
- const day_of_year::rep* year_data = days_in_year_before(leap);
- if (!(d <= year_data[m] - year_data[m - 1]))
- {
- return throw bad_date("");
- }
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[m - 1] + d;
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     rel_date::rel_date(chrono::year y, chrono::month m, day d)
     :
     y_(y),
     m_(m),
     leap_(is_leap(y)),
- dow_(weekday::not_applicable),
+ dow_(detail::weekday::not_applicable),
     d_(d),
- n_(nth_week::not_applicable)
+ n_(detail::nth_week::not_applicable)
     {
       const day_of_year::rep* year_data = days_in_year_before(leap_);
       if (!(d <= year_data[m] - year_data[m - 1]))
@@ -113,89 +62,26 @@
       }
 
     }
-#endif
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(year y, chrono::month m, day d) BOOST_NOEXCEPT
- :
- y_(y),
- m_(m),
- leap_(is_leap(y)),
- dow_(weekday::not_applicable),
- d_(d),
- n_(nth_week::not_applicable)
- {
- const day_of_year::rep* year_data = days_in_year_before(leap_);
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[m - 1] + d;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(chrono::year y, chrono::month m, day d)BOOST_NOEXCEPT
- {
- bool leap = is_leap(y);
- const day_of_year::rep* year_data = days_in_year_before(leap);
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[m - 1] + d;
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
     rel_date::rel_date(chrono::year y, chrono::month m, day d)BOOST_NOEXCEPT
     :
     y_(y),
     m_(m),
     leap_(is_leap(y)),
- dow_(weekday::not_applicable),
+ dow_(detail::weekday::not_applicable),
     d_(d),
- n_(nth_week::not_applicable)
- {
- }
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(chrono::year y, chrono::month_day md, check_t)
- :
- y_(y),
- m_(month(md)),
- leap_(is_leap(y)),
- dow_(weekday::not_applicable),
- d_(day(md)),
- n_(nth_week::not_applicable)
- {
- const day_of_year::rep* year_data = days_in_year_before(leap_);
- if (!(day(md) <= year_data[month(md)] - year_data[month(md) - 1]))
- {
- return throw bad_date("");
- }
- year::rep by = y.value() + 32799;
- x_ = days_before_year(by) + year_data[month(md) - 1] + day(md);
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(chrono::year y, chrono::month_day md, check_t)
+ n_(detail::nth_week::not_applicable)
     {
- bool leap = is_leap(y);
- const day_of_year::rep* year_data = days_in_year_before(leap);
- if (!(day(md) <= year_data[month(md)] - year_data[month(md) - 1]))
- {
- return throw bad_date("");
- }
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[month(md) - 1] + day(md);
     }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
     rel_date::rel_date(chrono::year y, chrono::month_day md, check_t)
     :
     y_(y),
     m_(month(md)),
     leap_(is_leap(y)),
- dow_(weekday::not_applicable),
+ dow_(detail::weekday::not_applicable),
     d_(day(md)),
- n_(nth_week::not_applicable)
+ n_(detail::nth_week::not_applicable)
     {
       const day_of_year::rep* year_data = days_in_year_before(leap_);
       if (!(d_ <= year_data[m_] - year_data[m_ - 1]))
@@ -204,46 +90,17 @@
       }
 
     }
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(year::rep y, chrono::month_day md)
- BOOST_NOEXCEPT :
- y_(y),
- m_(month(md)),
- leap_(is_leap(y)),
- dow_(weekday::not_applicable),
- d_(day(md)),
- n_(nth_week::not_applicable)
- {
- const day_of_year::rep* year_data = days_in_year_before(leap_);
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[month(md) - 1] + day(md);
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(year::rep y, chrono::month_day md)
- BOOST_NOEXCEPT {
- bool leap = is_leap(y);
- const day_of_year::rep* year_data = days_in_year_before(leap);
- year::rep by = y + 32799;
- x_ = days_before_year(by) + year_data[month(md) - 1] + day(md);
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
     rel_date::rel_date(year::rep y, chrono::month_day md)
     BOOST_NOEXCEPT :
     y_(y),
     m_(month(md)),
     leap_(is_leap(y)),
- dow_(weekday::not_applicable),
+ dow_(detail::weekday::not_applicable),
     d_(day(md)),
- n_(nth_week::not_applicable)
+ n_(detail::nth_week::not_applicable)
     {
     }
-#endif
 
     rel_date::rel_date(days d)
     {
@@ -261,26 +118,7 @@
           + to_string(y) );
     }
 
-//#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-//
-// rel_date::rel_date(year::rep y, day_of_year::rep d) // TODO
-// BOOST_NOEXCEPT
-// {
-//
-// }
-//
-//
-//
-//#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-//
-// rel_date::rel_date(year::rep y, day_of_year::rep d)// TODO
-// BOOST_NOEXCEPT
-// {
-//
-// }
-//
-//
-//#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
+
 //
 // rel_date::rel_date(year::rep y, day_of_year::rep d)// TODO
 // BOOST_NOEXCEPT
@@ -289,50 +127,6 @@
 // }
 //
 //
-//#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- bool rel_date::set_if_valid_date(chrono::year y, chrono::month m, day d) BOOST_NOEXCEPT
- {
- bool leap = is_leap(y);
- const day_of_year::rep* year_data = days_in_year_before(leap);
-
- if (!(d <= year_data[m] - year_data[m - 1]))
- {
- return false;
- }
- y_ = y.value();
- m_ = m.value();
- d_ = d.value();
- leap_ = leap;
- year::rep by = y.value() + 32799;
- x_ = days_before_year(by) + year_data[m - 1] + d;
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return true;
- }
-
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- bool rel_date::set_if_valid_date(chrono::year y, chrono::month m, day d) BOOST_NOEXCEPT
- {
- bool leap = is_leap(y.value());
- const day_of_year::rep* year_data = days_in_year_before(leap);
-
- if (!(d.value() <= year_data[m.value()] - year_data[m.value()-1]))
- {
- return false;
- }
- year::rep by = y.value() + 32799;
- x_ = days_before_year(by) + year_data[m.value()-1] + d.value();
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return true;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
     bool rel_date::set_if_valid_date(chrono::year y, chrono::month m, day d) BOOST_NOEXCEPT
     {
@@ -347,45 +141,11 @@
       m_ = m.value();
       d_ = d.value();
       leap_ = leap;
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
+ dow_=detail::weekday::not_applicable;
+ n_=detail::nth_week::not_applicable;
       return true;
     }
 
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- bool rel_date::set_if_valid_date(chrono::year y, day_of_year doy) BOOST_NOEXCEPT
-
- {
- bool leap = is_leap(y);
- if (!leap && doy == 366)
- return false;
-
- y_ = y.value();
- m_ = day_of_year_month(leap,doy);
- d_ = day_of_year_day_of_month(leap,doy);
- leap_ = leap;
- year::rep by = y.value() + 32799;
- x_ = days_before_year(by) + doy -1;
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return true;
- }
-
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- bool rel_date::set_if_valid_date(chrono::year y, day_of_year doy) BOOST_NOEXCEPT// TODO
- {
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return false;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     bool rel_date::set_if_valid_date(year y, day_of_year doy) BOOST_NOEXCEPT
     {
       bool leap = is_leap(y);
@@ -396,45 +156,11 @@
       m_ = day_of_year_month(leap,doy);
       d_ = day_of_year_day_of_month(leap,doy);
       leap_ = leap;
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return true;
- }
-
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- bool rel_date::set_if_valid_date(days x) BOOST_NOEXCEPT
- {
- if (!(11322 <= x.count() && x.count() <= 23947853))
- {
- return false;
- }
- year_month_day_leap dt = to_ymd_leap(x);
- y_=year(dt);
- m_=month(dt);
- d_=day(dt);
- leap_=dt.is_leap_year();
- x_=x.count();
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
+ dow_=detail::weekday::not_applicable;
+ n_=detail::nth_week::not_applicable;
       return true;
-
- }
-
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- bool rel_date::set_if_valid_date(days x) BOOST_NOEXCEPT// TODO
- {
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
- return false;
     }
 
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     bool rel_date::set_if_valid_date(days x) BOOST_NOEXCEPT
     {
       if (!(11322 <= x.count() && x.count() <= 23947853))
@@ -446,55 +172,32 @@
       m_=month(dt);
       d_=day(dt);
       leap_=dt.is_leap_year();
- dow_=weekday::not_applicable;
- n_=nth_week::not_applicable;
+ dow_=detail::weekday::not_applicable;
+ n_=detail::nth_week::not_applicable;
       return true;
 
     }
 
-#endif
-
-
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- bool rel_date::is_valid() const BOOST_NOEXCEPT
- {
- return x_ >= 11322 && x_ <= 23947853;
-
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- bool rel_date::is_valid() const
- BOOST_NOEXCEPT
- {
- return x_ >= 11322 && x_ <= 23947853;
-
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     bool rel_date::is_valid() const BOOST_NOEXCEPT
     {
       if (chrono::year(y_).is_valid() && chrono::month(m_).is_valid())
       {
         if (d_!=0 && day(d_).is_valid()) {
- const day_of_year::rep* year_data = days_in_year_before(leap_);
+ const day_of_year::rep* year_data = days_in_year_before(leap_);
 
- if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_ - 1]))
- {
- return false;
- }
- else
- {
- return true;
- }
+ if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_ - 1]))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
         } else return true;
       }
       return false;
 
     }
-#endif
 
     rel_date
     rel_date::today()
@@ -532,44 +235,13 @@
 
 #endif //BOOST_CHRONO_DATE_REL_DATE_IS_A_MODEL_OF_DATE
 
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-// rel_date::rel_date(ymd_date dt) :
-// x_(dt.days_since_epoch().count()),
-// y_(year(dt).value()),
-// m_(month(dt).value()),
-// leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
-// d_(day(dt).value()),
-// n_(nth_week::not_applicable)
-// {
-//
-// }
- rel_date::operator ymd_date() const
- {
- return ymd_date(x_, y_, m_, d_, leap_);
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
-// rel_date::rel_date(ymd_date dt) :
-// x_(dt.days_since_epoch().count())
-// {
-//
-// }
- rel_date::operator ymd_date() const
- {
- return days_date(x_);
-
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
 // rel_date::rel_date(ymd_date dt) :
 // y_(year(dt).value()),
 // m_(month(dt).value()),
 // leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
+// dow_(detail::weekday::not_applicable),
 // d_(day(dt).value()),
-// n_(nth_week::not_applicable)
+// n_(detail::nth_week::not_applicable)
 // {
 //
 // }
@@ -578,659 +250,125 @@
       return ymd_date(y_,m_,d_,leap_);
 
     }
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
 
 // rel_date::rel_date(days_date dt) :
-// x_(dt.days_since_epoch().count()),
 // y_(year(dt).value()),
 // m_(month(dt).value()),
 // leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
+// dow_(detail::weekday::not_applicable),
 // d_(day(dt).value()),
-// n_(nth_week::not_applicable)
-// {
-//
-// }
- rel_date::operator days_date() const
- {
- return days_date(x_);
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
-// rel_date::rel_date(days_date dt) :
-// x_(dt.days_since_epoch().count())
+// n_(detail::nth_week::not_applicable)
 // {
 //
 // }
     rel_date::operator days_date() const
     {
- return days_date(x_);
+ // @todo improve this
+ return days_date(ymd_date(y_,m_,d_,leap_));
 
     }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
-// rel_date::rel_date(days_date dt) :
+// rel_date::rel_date(ydoy_date dt) :
 // y_(year(dt).value()),
 // m_(month(dt).value()),
 // leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
+// dow_(detail::weekday::not_applicable),
 // d_(day(dt).value()),
-// n_(nth_week::not_applicable)
+// n_(detail::nth_week::not_applicable)
 // {
 //
 // }
- rel_date::operator days_date() const
+ rel_date::operator ydoy_date() const
     {
       // @todo improve this
- return days_date(ymd_date(y_,m_,d_,leap_));
+ return ydoy_date(ymd_date(y_,m_,d_,leap_));
 
     }
-#endif
 
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
-// rel_date::rel_date(ydoy_date dt) :
-// x_(dt.days_since_epoch().count()),
-// y_(year(dt).value()),
-// m_(month(dt).value()),
-// leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
-// d_(day(dt).value()),
-// n_(nth_week::not_applicable)
-// {
-//
-// }
- rel_date::operator ydoy_date() const
- {
- return date(x_, y_, m_, d_, leap_);
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
-// rel_date::rel_date(ydoy_date dt) :
-// x_(dt.days_since_epoch().count())
-// {
-//
-// }
- rel_date::operator ydoy_date() const
- {
- return date(x_);
-
- }
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
-// rel_date::rel_date(ydoy_date dt) :
-// y_(year(dt).value()),
-// m_(month(dt).value()),
-// leap_(dt.is_leap_year()),
-// dow_(weekday::not_applicable),
-// d_(day(dt).value()),
-// n_(nth_week::not_applicable)
-// {
-//
-// }
- rel_date::operator ydoy_date() const
- {
- // @todo improve this
- return ydoy_date(ymd_date(y_,m_,d_,leap_));
-
- }
-#endif
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(chrono::year y, chrono::month m, nth_weekday d) :
- y_(y.value()),
+ rel_date::rel_date(chrono::year y, chrono::month m, nth_weekday rd)
+ : y_(y.value()),
     m_(m.value()),
- dow_(weekday(d)),
+ leap_(0),
+ dow_(weekday(rd)),
+ //d_(rd.d_),
     d_(0),
- n_(nth_week(d))
+ n_(nth_week(rd))
     {
- leap_ = chrono::year(y_).is_leap();
+ leap_ = chrono::year(y).is_leap();
       const day_of_year::rep* year_data = days_in_year_before(leap_);
- if (n_ != nth_week::not_applicable) // if a nth is involved
-
       {
- if (dow_ == weekday::not_applicable) // if we want nth day of month
 
+ // dow_ = [0 - 5] 0 means last
+ // n_ = [0 - 5] 0 means last
+ int32_t by = y.value() + 32799;
+ int32_t fy = by*365 + by/4 - by/100 + by/400;
+ int n_days_in_month = year_data[m_] - year_data[m_-1];
+ int d;
+ int fdow = (fy + year_data[m_-1] + 2) % weekday::size;
+ d = 1 + (n_-1) * weekday::size;
+ if (dow_ < fdow)
         {
- if (n_ == last.value_) // want last day of month
-
- {
- d_ = year_data[m_] - year_data[m_ - 1];
- }
- else
- {
- d_ = n_; // want nth day of month
- }
+ d += weekday::size - (fdow - dow_);
         }
- else // we want nth weekday of month
-
+ else if (dow_ > fdow)
         {
- // dow_ = [0 - 6]
- // n_ = [1 - 6] 6 means last
- int32_t by = y.value() + 32799;
- int32_t fy = by * 365 + by / 4 - by / 100 + by / 400;
- int n_days_in_month = year_data[m_] - year_data[m_ - 1];
- int d;
- if (n_ == last.value_)
- {
- int ldow = (fy + year_data[m_] + 1) % weekday::size;
- d = n_days_in_month;
- if (dow_ < ldow)
- {
- d -= ldow - dow_;
- }
- else if (dow_ > ldow)
- {
- d -= weekday::size - (dow_ - ldow);
- }
- }
- else
- {
- int fdow = (fy + year_data[m_ - 1] + 2) % weekday::size;
- d = 1 + (n_ - 1) * weekday::size;
- if (dow_ < fdow)
- {
- d += weekday::size - (fdow - dow_);
- }
- else if (dow_ > fdow)
- {
- d += dow_ - fdow;
- }
- if (d > n_days_in_month)
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y_) + '-' + to_string(m_));
- }
- }
- d_ = d;
- x_ = fy + year_data[m_ - 1] + d_;
- return;
+ d += dow_ - fdow;
         }
- }
- if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_ - 1]))
- {
- throw bad_date("day " + to_string(d_) + " is out of range for "
- + to_string(y_) + '-' + to_string(m_));
- }
- int32_t by = y.value() + 32799;
- x_ = by * 365 + by / 4 - by / 100 + by / 400 + year_data[m_ - 1] + d_;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(year y, chrono::month m, nth_weekday nwd) :
- n_(nth_week(nwd)), dow_(weekday(nwd))
- {
- bool leap = y.is_leap();
- const day_of_year::rep* year_data = days_in_year_before(leap);
- if (n_ != nth_week::not_applicable) // if a nth is involved
-
- {
- if (dow_ == weekday::not_applicable) // if we want nth day of month
-
+ if (d > n_days_in_month)
         {
- int d;
- if (n_ == last.value_) // want last day of month
-
- {
- d = year_data[m.value()] - year_data[m.value() - 1];
- }
- else
- {
- d = n_; // want nth day of month
- }
- if (!(1 <= d && d <= year_data[m.value()] - year_data[m.value() - 1]))
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y.value()) + '-' + to_string(m.value()));
- }
- int32_t by = y.value() + 32799;
- x_ = by * 365 + by / 4 - by / 100 + by / 400 + year_data[m.value()
- - 1] + d;
- return;
- }
- else // we want nth weekday of month
-
- {
- // dow_ = [0 - 6]
- // n_ = [1 - 6] 6 means last
- int32_t by = y.value() + 32799;
- int32_t fy = by * 365 + by / 4 - by / 100 + by / 400;
- int n_days_in_month = year_data[m.value()] - year_data[m.value() - 1];
- int d;
- if (n_ == last.value_)
- {
- int ldow = (fy + year_data[m.value()] + 1) % weekday::size;
- d = n_days_in_month;
- if (dow_ < ldow)
- {
- d -= ldow - dow_;
- }
- else if (dow_ > ldow)
- {
- d -= weekday::size - (dow_ - ldow);
- }
- }
- else
- {
- int fdow = (fy + year_data[m.value() - 1] + 2) % weekday::size;
- d = 1 + (n_ - 1) * weekday::size;
- if (dow_ < fdow)
- {
- d += weekday::size - (fdow - dow_);
- }
- else if (dow_ > fdow)
- {
- d += dow_ - fdow;
- }
- if (d > n_days_in_month)
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y.value()) + '-' + to_string(m.value()));
- }
- }
- x_ = fy + year_data[m.value() - 1] + d;
- return;
+ throw bad_date("day " + to_string(int(d)) +
+ " is out of range for " + to_string(y_) +
+ '-' + to_string(int(m_)));
         }
+ d_ = d;
       }
- // if (!(1 <= d.d_ && d.d_ <= year_data[m.value()] - year_data[m.value()-1]))
- // {
- // throw bad_date("day " + to_string(d.d_) +
- // " is out of range for " + to_string(y.value()) +
- // '-' + to_string(m.value()));
- // }
- // int32_t by = y.value() + 32799;
- // x_ = by*365 + by/4 - by/100 + by/400 + year_data[m.value()-1] + d.d_;
     }
 
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
- rel_date::rel_date(chrono::year y, chrono::month m, nth_weekday rd)
+ rel_date::rel_date(chrono::year y, chrono::month m, last_weekday rd)
     : y_(y.value()),
     m_(m.value()),
     leap_(0),
     dow_(weekday(rd)),
     //d_(rd.d_),
     d_(0),
- n_(nth_week(rd))
+ n_(0)
     {
- std::cout <<" =========== d= "<< int(d_) << std::endl;
-
       leap_ = chrono::year(y).is_leap();
       const day_of_year::rep* year_data = days_in_year_before(leap_);
-// if (n_ != nth_week::not_applicable) // if a nth is involved
-
- {
-// if (dow_ == weekday::not_applicable) // if we want nth day of month
-//
-// {
-// if (n_ == last.value_) // want last day of month
-//
-// {
-// d_ = year_data[m_] - year_data[m_-1];
-// std::cout <<" =========== d= "<< int(d_) << std::endl;
-// }
-// else
-// {
-// d_ = n_; // want nth day of month
-// std::cout <<" =========== d= "<< int(d_) << std::endl;
-// }
-// }
-// else // we want nth weekday of month
-
- {
- // dow_ = [0 - 5] 0 means last
- // n_ = [0 - 5] 0 means last
- int32_t by = y.value() + 32799;
- int32_t fy = by*365 + by/4 - by/100 + by/400;
- int n_days_in_month = year_data[m_] - year_data[m_-1];
- int d;
- if (n_ == last.value_)
- {
- int ldow = (fy + year_data[m_] + 1) % weekday::size;
- d = n_days_in_month;
- if (dow_ < ldow)
- {
- d -= ldow - dow_;
- }
- else if (dow_ > ldow)
- {
- d -= weekday::size - (dow_ - ldow);
- }
- }
- else
- {
- int fdow = (fy + year_data[m_-1] + 2) % weekday::size;
- d = 1 + (n_-1) * weekday::size;
- if (dow_ < fdow)
- {
- d += weekday::size - (fdow - dow_);
- }
- else if (dow_ > fdow)
- {
- d += dow_ - fdow;
- }
- if (d > n_days_in_month)
- {
- throw bad_date("day " + to_string(int(d)) +
- " is out of range for " + to_string(y_) +
- '-' + to_string(int(m_)));
- }
- }
- d_ = d;
- std::cout <<" =========== d= "<< int(d_) << std::endl;
- }
- }
-// if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_-1]))
-// {
-// std::cout <<"===== ====== d= "<< int(d_) << std::endl;
-// throw bad_date("day " + to_string(int(d_)) +
-// " is out of range for " + to_string(y_) +
-// '-' + to_string(int(m_)));
-// }
- }
-
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-
- rel_date::rel_date(chrono::year y, chrono::month m, nth n) :
- y_(y.value()),
- m_(m.value()),
- dow_(weekday::not_applicable),
- d_(0),
- n_(n.value())
- {
- leap_ = chrono::year(y_).is_leap();
- const day_of_year::rep* year_data = days_in_year_before(leap_);
- if (n_ != nth_week::not_applicable) // if a nth is involved
-
- {
- if (dow_ == weekday::not_applicable) // if we want nth day of month
-
- {
- if (n_ == last.value_) // want last day of month
-
- {
- d_ = year_data[m_] - year_data[m_ - 1];
- }
- else
- {
- d_ = n_; // want nth day of month
- }
- }
- else // we want nth weekday of month
+ // dow_ = [0 - 5] 0 means last
+ // n_ = [0 - 5] 0 means last
+ int32_t by = y.value() + 32799;
+ int32_t fy = by*365 + by/4 - by/100 + by/400;
+ int n_days_in_month = year_data[m_] - year_data[m_-1];
+ int d;
 
- {
- // dow_ = [0 - 6]
- // n_ = [1 - 6] 6 means last
- int32_t by = y.value() + 32799;
- int32_t fy = by * 365 + by / 4 - by / 100 + by / 400;
- int n_days_in_month = year_data[m_] - year_data[m_ - 1];
- int d;
- if (n_ == last.value_)
- {
- int ldow = (fy + year_data[m_] + 1) % weekday::size;
- d = n_days_in_month;
- if (dow_ < ldow)
- {
- d -= ldow - dow_;
- }
- else if (dow_ > ldow)
- {
- d -= weekday::size - (dow_ - ldow);
- }
- }
- else
- {
- int fdow = (fy + year_data[m_ - 1] + 2) % weekday::size;
- d = 1 + (n_ - 1) * weekday::size;
- if (dow_ < fdow)
- {
- d += weekday::size - (fdow - dow_);
- }
- else if (dow_ > fdow)
- {
- d += dow_ - fdow;
- }
- if (d > n_days_in_month)
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y_) + '-' + to_string(m_));
- }
- }
- d_ = d;
- x_ = fy + year_data[m_ - 1] + d_;
- return;
- }
- }
- if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_ - 1]))
+ int ldow = (fy + year_data[m_] + 1) % weekday::size;
+ d = n_days_in_month;
+ if (dow_ < ldow)
       {
- throw bad_date("day " + to_string(d_) + " is out of range for "
- + to_string(y_) + '-' + to_string(m_));
+ d -= ldow - dow_;
       }
- int32_t by = y.value() + 32799;
- x_ = by * 365 + by / 4 - by / 100 + by / 400 + year_data[m_ - 1] + d_;
- }
-
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date::rel_date(chrono::year y, chrono::month m, nth n) :
- n_(n.value()), dow_(weekday::not_applicable)
- {
- bool leap = y.is_leap();
- const day_of_year::rep* year_data = days_in_year_before(leap);
- if (n_ != nth_week::not_applicable) // if a nth is involved
-
+ else if (dow_ > ldow)
       {
- if (dow_ == weekday::not_applicable) // if we want nth day of month
-
- {
- int d;
- if (n_ == last.value_) // want last day of month
-
- {
- d = year_data[m.value()] - year_data[m.value() - 1];
- }
- else
- {
- d = n_; // want nth day of month
- }
- if (!(1 <= d && d <= year_data[m.value()] - year_data[m.value() - 1]))
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y.value()) + '-' + to_string(m.value()));
- }
- int32_t by = y.value() + 32799;
- x_ = by * 365 + by / 4 - by / 100 + by / 400 + year_data[m.value()
- - 1] + d;
- return;
- }
- else // we want nth weekday of month
-
- {
- // dow_ = [0 - 6]
- // n_ = [1 - 6] 6 means last
- int32_t by = y.value() + 32799;
- int32_t fy = by * 365 + by / 4 - by / 100 + by / 400;
- int n_days_in_month = year_data[m.value()] - year_data[m.value() - 1];
- int d;
- if (n_ == last.value_)
- {
- int ldow = (fy + year_data[m.value()] + 1) % weekday::size;
- d = n_days_in_month;
- if (dow_ < ldow)
- {
- d -= ldow - dow_;
- }
- else if (dow_ > ldow)
- {
- d -= weekday::size - (dow_ - ldow);
- }
- }
- else
- {
- int fdow = (fy + year_data[m.value() - 1] + 2) % weekday::size;
- d = 1 + (n_ - 1) * weekday::size;
- if (dow_ < fdow)
- {
- d += weekday::size - (fdow - dow_);
- }
- else if (dow_ > fdow)
- {
- d += dow_ - fdow;
- }
- if (d > n_days_in_month)
- {
- throw bad_date("day " + to_string(d) + " is out of range for "
- + to_string(y.value()) + '-' + to_string(m.value()));
- }
- }
- x_ = fy + year_data[m.value() - 1] + d;
- return;
- }
+ d -= weekday::size - (dow_ - ldow);
       }
- // if (!(1 <= d.d_ && d.d_ <= year_data[m.value()] - year_data[m.value()-1]))
- // {
- // throw bad_date("day " + to_string(d.d_) +
- // " is out of range for " + to_string(y.value()) +
- // '-' + to_string(m.value()));
- // }
- // int32_t by = y.value() + 32799;
- // x_ = by*365 + by/4 - by/100 + by/400 + year_data[m.value()-1] + d.d_;
+ d_ = d;
     }
 
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
- rel_date::rel_date(chrono::year y, chrono::month m, nth n)
+ rel_date::rel_date(chrono::year y, chrono::month m, last_tag)
     : y_(y.value()),
     m_(m.value()),
     leap_(0),
- dow_(weekday::not_applicable),
- //d_(rd.d_),
+ dow_(detail::weekday::not_applicable),
     d_(0),
- n_(n.value())
+ n_(0)
     {
       leap_ = y.is_leap();
       const day_of_year::rep* year_data = days_in_year_before(leap_);
-// if (n_ != nth_week::not_applicable) // if a nth is involved
-
- {
-// if (dow_ == weekday::not_applicable) // if we want nth day of month
-
- {
- if (n_ == last.value_) // want last day of month
-
- {
- d_ = year_data[m_] - year_data[m_-1];
- }
- else
- {
- d_ = n_; // want nth day of month
- }
- }
-// else // we want nth weekday of month
-//
-// {
-// // dow_ = [0 - 6]
-// // n_ = [1 - 6] 6 means last
-// int32_t by = y.value() + 32799;
-// int32_t fy = by*365 + by/4 - by/100 + by/400;
-// int n_days_in_month = year_data[m_] - year_data[m_-1];
-// int d;
-// if (n_ == last.value_)
-// {
-// int ldow = (fy + year_data[m_] + 1) % weekday::size;
-// d = n_days_in_month;
-// if (dow_ < ldow)
-// {
-// d -= ldow - dow_;
-// }
-// else if (dow_ > ldow)
-// {
-// d -= weekday::size - (dow_ - ldow);
-// }
-// }
-// else
-// {
-// int fdow = (fy + year_data[m_-1] + 2) % weekday::size;
-// d = 1 + (n_-1) * weekday::size;
-// if (dow_ < fdow)
-// {
-// d += weekday::size - (fdow - dow_);
-// }
-// else if (dow_ > fdow)
-// {
-// d += dow_ - fdow;
-// }
-// if (d > n_days_in_month)
-// {
-// throw bad_date("day " + to_string(int(d)) +
-// " is out of range for " + to_string(y_) +
-// '-' + to_string(int(m_)));
-// }
-// }
-// d_ = d;
-// }
- }
-// if (!(1 <= d_ && d_ <= year_data[m_] - year_data[m_-1]))
-// {
-// throw bad_date("day " + to_string(int(d_)) +
-// " is out of range for " + to_string(y_) +
-// '-' + to_string(int(m_)));
-// }
+ d_ = year_data[m_] - year_data[m_-1];
     }
 
-#endif
 
-//#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1
-//
-// rel_date&
-// rel_date::operator+=(days d)
-// {
-// x_ += d.count();
-// if (!(11322 <= x_ && x_ <= 23947853))
-// {
-// throw bad_date("year is out of range [-32768, 32767]");
-// }
-// year::rep y = to_average_year(x_);
-// int doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
-// if (doy < 0)
-// {
-// --y;
-// doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
-// }
-// y_ = static_cast<int16_t> (y - 32799);
-// leap_ = year(y).is_leap();
-// const day_of_year::rep* year_data = days_in_year_before(leap_);
-// m_ = static_cast<uint16_t> (std::lower_bound(year_data, year_data + 13, doy)
-// - year_data);
-// d_ = static_cast<uint16_t> (doy - year_data[m_ - 1]);
-// n_ = nth_week::not_applicable;
-// dow_ = weekday::not_applicable;
-// return *this;
-// }
-//
-//#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-//
-// rel_date&
-// rel_date::operator+=(days d)
-// {
-// x_ += d.count();
-// if (!(11322 <= x_ && x_ <= 23947853))
-// {
-// throw bad_date("year is out of range [-32768, 32767]");
-// }
-// n_ = nth_week::not_applicable;
-// dow_ = weekday::not_applicable;
-// return *this;
-// }
-//
-//#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 //
 // rel_date&
 // rel_date::operator+=(days d)
@@ -1256,14 +394,11 @@
 // d_ = static_cast<uint16_t>(doy - year_data[m_-1]);
 //
 //
-// n_ = nth_week::not_applicable;
-// dow_ = weekday::not_applicable;
+// n_ = detail::nth_week::not_applicable;
+// dow_ = detail::weekday::not_applicable;
 // return *this;
 // }
 //
-//#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 1 || BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
 
     rel_date&
     rel_date::operator+=(months mn)
@@ -1283,10 +418,13 @@
         y += dy;
         m -= 12 * dy;
       }
- //if (d_==0)
+
+ if (dow_==detail::weekday::not_applicable)
+ *this = last/chrono::month(m)/y;
+ else if (n_==0)
+ *this = last_weekday(chrono::weekday(dow_)) / chrono::month(m) / y;
+ else
         *this = nth_weekday(nth_week(n_), chrono::weekday(dow_)) / chrono::month(m) / y;
- //else
- //*this = rel_date(year(y), chrono::month(m), day(d_));
       return *this;
     }
 
@@ -1301,130 +439,6 @@
 
     }
 
-#elif BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- rel_date&
- rel_date::operator+=(months mn)
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
- }
- y -= 32799;
- bool leap = year(y).is_leap();
- const day_of_year::rep* year_data = days_in_year_before(leap);
- int m = std::lower_bound(year_data, year_data + 13, doy) - year_data;
- m += mn.count();
- if (m < 1)
- {
- int dy = (12 - m) / 12;
- y -= dy;
- m += 12 * dy;
- }
- else if (m > 12)
- {
- int dy = (m - 1) / 12;
- y += dy;
- m -= 12 * dy;
- }
- *this = nth_weekday(nth_week(n_), chrono::weekday(dow_))
- / chrono::month(m) / y;
- return *this;
- }
-
- rel_date&
- rel_date::operator+=(years yr)
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y * 365 + y / 4 - y / 100 + y / 400);
- }
- y -= 32799;
- bool leap = year(y).is_leap();
- const day_of_year::rep* year_data = days_in_year_before(leap);
- int m = std::lower_bound(year_data, year_data + 13, doy) - year_data;
- *this = nth_weekday(nth_week(n_), chrono::weekday(dow_))
- / chrono::month(m) / (y + yr.count());
- return *this;
- }
-
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 2
-
- uint16_t
- rel_date::day_from_day_number() const
- BOOST_NOEXCEPT
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y*365 + y/4 - y/100 + y/400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y*365 + y/4 - y/100 + y/400);
- }
- y -= 32799;
- const day_of_year::rep* year_data = days_in_year_before(chrono::year(y).is_leap());
- int m = std::lower_bound(year_data, year_data+13, doy) - year_data;
- return static_cast<uint16_t>(doy - year_data[m-1]);
- }
-
- uint16_t
- rel_date::month_from_day_number() const
- BOOST_NOEXCEPT
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y*365 + y/4 - y/100 + y/400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y*365 + y/4 - y/100 + y/400);
- }
- y -= 32799;
- const day_of_year::rep* year_data = days_in_year_before(chrono::year(y).is_leap());
- return std::lower_bound(year_data, year_data+13, doy) - year_data;
- }
-
- int16_t
- rel_date::year_from_day_number() const
- BOOST_NOEXCEPT
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y*365 + y/4 - y/100 + y/400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y*365 + y/4 - y/100 + y/400);
- }
- y -= 32799;
- return static_cast<int16_t>(y);
- }
-
- bool
- rel_date::leap_from_day_number() const
- BOOST_NOEXCEPT
- {
- year::rep y = to_average_year(x_);
- int doy = x_ - (y*365 + y/4 - y/100 + y/400);
- if (doy < 0)
- {
- --y;
- doy = x_ - (y*365 + y/4 - y/100 + y/400);
- }
- y -= 32799;
- return chrono::year(y).is_leap();
- }
-
-#endif
-
-#if BOOST_CHRONO_DATE_REL_DATE_DESIGN == 3
-
     uint32_t
     rel_date::day_number_from_ymd() const BOOST_NOEXCEPT
     {
@@ -1433,8 +447,6 @@
       return by*365 + by/4 - by/100 + by/400 + year_data[m_-1] + d_;
     }
 
-#endif
-
     year_month_day to_ymd(year_week_weekday p)
     BOOST_NOEXCEPT
     {
@@ -1494,11 +506,10 @@
 
     }
 
- year_week_weekday to_ywwd(days dt)
-BOOST_NOEXCEPT {
- return to_ywwd(to_ymd(dt));
-
- }
+ year_week_weekday to_ywwd(days dt) BOOST_NOEXCEPT
+ {
+ return to_ywwd(to_ymd(dt));
+ }
 
 } // chrono
 } // boost

Modified: sandbox/chrono_date/libs/date/src/vars.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/src/vars.cpp (original)
+++ sandbox/chrono_date/libs/date/src/vars.cpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -9,7 +9,7 @@
 #include <boost/chrono/date/weekday.hpp>
 #include <boost/chrono/date/month.hpp>
 #include <boost/chrono/date/nth_week.hpp>
-#include <boost/chrono/date/nth.hpp>
+//#include <boost/chrono/date/nth.hpp>
 #include <boost/chrono/date/month_nth.hpp>
 #include <boost/chrono/date/tuples.hpp>
 
@@ -18,18 +18,18 @@
   namespace chrono
   {
 
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, last, 0)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _1st, 1)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _2nd, 2)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _3rd, 3)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _4th, 4)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _5th, 5)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _6th, 6)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _7th, 7)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _8th, 8)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _9th, 9)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _10th, 10)
- BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, _29th, 29)
+ //BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_tag, last, 0)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_1_5_tag, _1st, 1)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_1_5_tag, _2nd, 2)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_1_5_tag, _3rd, 3)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_1_5_tag, _4th, 4)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_1_5_tag, _5th, 5)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _6th, 6)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _7th, 7)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _8th, 8)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _9th, 9)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _10th, 10)
+ BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(nth_6_31_tag, _29th, 29)
 
     BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(month, jan, 1)
     BOOST_CONSTEXPR_OR_EXTERN_CONST_DEF(month, feb, 2)

Modified: sandbox/chrono_date/libs/date/test/Jamfile.v2
==============================================================================
--- sandbox/chrono_date/libs/date/test/Jamfile.v2 (original)
+++ sandbox/chrono_date/libs/date/test/Jamfile.v2 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -131,7 +131,7 @@
     test-suite "wrappers"
         :
         [ date-run-2 wrappers/day_pass.cpp : day_pass ]
- [ date-run-2 wrappers/nth_pass.cpp : nth_pass ]
+ #[ date-run-2 wrappers/nth_pass.cpp : nth_pass ]
         [ date-run-2 wrappers/weekday_pass.cpp : weekday_pass ]
         [ date-run-2 wrappers/day_of_year_pass.cpp : day_of_year_pass ]
         [ date-run-2 wrappers/nth_week_pass.cpp : nth_week_pass ]

Modified: sandbox/chrono_date/libs/date/test/wrappers/nth_week_pass.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/test/wrappers/nth_week_pass.cpp (original)
+++ sandbox/chrono_date/libs/date/test/wrappers/nth_week_pass.cpp 2013-05-19 19:29:47 EDT (Sun, 19 May 2013)
@@ -24,7 +24,7 @@
   {
     try
     {
- nth_week d(7, check);
+ nth_week d(6, check);
       BOOST_TEST(false && "7 is not a valid nth_week");
     }
     catch (...)
@@ -53,10 +53,6 @@
       BOOST_TEST(d.is_valid() );
   }
   {
- nth_week d(6);
- BOOST_TEST(d.is_valid() );
- }
- {
       nth_week d(2);
       BOOST_TEST(d.is_valid() && "2 is a valid nth_week");
       nth_week::rep i = d;
@@ -88,10 +84,6 @@
 // BOOST_TEST(_5th_week.is_valid() );
 // BOOST_TEST(_5th_week==nth_week(5));
 // }
-// {
-// BOOST_TEST(last_week.is_valid() );
-// BOOST_TEST(last_week==nth_week(6));
-// }
 
   return boost::report_errors();
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk