Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84973 - in trunk: boost/chrono/io libs/chrono/test/io
From: vicente.botet_at_[hidden]
Date: 2013-07-07 12:08:55


Author: viboes
Date: 2013-07-07 12:08:54 EDT (Sun, 07 Jul 2013)
New Revision: 84973
URL: http://svn.boost.org/trac/boost/changeset/84973

Log:
Chrono: Manage with more time_point io format flags and tests.

Text files modified:
   trunk/boost/chrono/io/time_point_io.hpp | 303 ++++++++++++++++++++++-----------------
   trunk/libs/chrono/test/io/time_point_input.cpp | 26 +++
   trunk/libs/chrono/test/io/time_point_output.cpp | 21 ++
   3 files changed, 216 insertions(+), 134 deletions(-)

Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp Sun Jul 7 11:29:01 2013 (r84972)
+++ trunk/boost/chrono/io/time_point_io.hpp 2013-07-07 12:08:54 EDT (Sun, 07 Jul 2013) (r84973)
@@ -158,8 +158,7 @@
                 err |= std::ios_base::failbit;
         }
 
- void
- get_second(int& s,
+ void get_second(int& s,
                                                        iter_type& b, iter_type e,
                                                        std::ios_base::iostate& err,
                                                        const std::ctype<char_type>& ct) const
@@ -171,7 +170,101 @@
                 err |= std::ios_base::failbit;
         }
 
+ void get_white_space(iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ for (; b != e && ct.is(std::ctype_base::space, *b); ++b)
+ ;
+ if (b == e)
+ err |= std::ios_base::eofbit;
+ }
+
+ void get_12_hour(int& h,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 2);
+ if (!(err & std::ios_base::failbit) && 1 <= t && t <= 12)
+ h = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+
+ void get_percent(iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ if (b == e)
+ {
+ err |= std::ios_base::eofbit | std::ios_base::failbit;
+ return;
+ }
+ if (ct.narrow(*b, 0) != '%')
+ err |= std::ios_base::failbit;
+ else if(++b == e)
+ err |= std::ios_base::eofbit;
+ }
+
+ void get_day_year_num(int& d,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ int t = get_up_to_n_digits(b, e, err, ct, 3);
+ if (!(err & std::ios_base::failbit) && t <= 365)
+ d = t;
+ else
+ err |= std::ios_base::failbit;
+ }
+#if 0
+ void
+ get_weekdayname(int& w,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ // Note: ignoring case comes from the POSIX strptime spec
+ const string_type* wk = weeks();
+ ptrdiff_t i = detail::scan_keyword(b, e, wk, wk+14, ct, err, false) - wk;
+ if (i < 14)
+ w = i % 7;
+ }
+
+ void
+ get_monthname(int& m,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ // Note: ignoring case comes from the POSIX strptime spec
+ const string_type* month = months();
+ ptrdiff_t i = detail::scan_keyword(b, e, month, month+24, ct, err, false) - month;
+ if (i < 24)
+ m = i % 12;
+ }
+
+ void
+ get_am_pm(int& h,
+ iter_type& b, iter_type e,
+ std::ios_base::iostate& err,
+ const std::ctype<char_type>& ct) const
+ {
+ const string_type* ap = am_pm();
+ if (ap[0].size() + ap[1].size() == 0)
+ {
+ err |= ios_base::failbit;
+ return;
+ }
+ ptrdiff_t i = detail::scan_keyword(b, e, ap, ap+2, ct, err, false) - ap;
+ if (i == 0 && h == 12)
+ h = 0;
+ else if (i == 1 && h < 12)
+ h += 12;
+ }
 
+#endif
 
         InputIterator get(
             iter_type b, iter_type e,
@@ -187,104 +280,98 @@
             {
 // case 'a':
 // case 'A':
-// that_.get_weekdayname(tm->tm_wday, b, e, err, ct);
-// break;
+// get_weekdayname(tm->tm_wday, b, e, err, ct);
+// break;
 // case 'b':
 // case 'B':
 // case 'h':
-// that_.get_monthname(tm->tm_mon, b, e, err, ct);
-// break;
+// get_monthname(tm->tm_mon, b, e, err, ct);
+// break;
 // case 'c':
-// {
-// const string_type& fm = this->c();
+// {
+// const string_type& fm = c();
 // b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
-// }
-// break;
+// }
+// break;
             case 'd':
             case 'e':
               get_day(tm->tm_mday, b, e, err, ct);
- //std::cerr << "tm_mday= "<< tm->tm_mday << std::endl;
-
- break;
-// case 'D':
-// {
-// const char_type fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
-// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
-// }
-// break;
-// case 'F':
-// {
-// const char_type fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
-// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
-// }
-// break;
+ break;
+ case 'D':
+ {
+ const char_type fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
+ b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+ }
+ break;
+ case 'F':
+ {
+ const char_type fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
+ b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+ }
+ break;
             case 'H':
               get_hour(tm->tm_hour, b, e, err, ct);
- //std::cerr << "tm_hour= "<< tm->tm_hour << std::endl;
- break;
-// case 'I':
-// that_.get_12_hour(tm->tm_hour, b, e, err, ct);
-// break;
-// case 'j':
-// that_.get_day_year_num(tm->tm_yday, b, e, err, ct);
-// break;
+ break;
+ case 'I':
+ get_12_hour(tm->tm_hour, b, e, err, ct);
+ break;
+ case 'j':
+ get_day_year_num(tm->tm_yday, b, e, err, ct);
+ break;
             case 'm':
               get_month(tm->tm_mon, b, e, err, ct);
- //std::cerr << "tm_mon= "<< tm->tm_mon << std::endl;
- break;
+ break;
             case 'M':
               get_minute(tm->tm_min, b, e, err, ct);
- //std::cerr << "tm_min= "<< tm->tm_min << std::endl;
- break;
-// case 'n':
-// case 't':
-// that_.get_white_space(b, e, err, ct);
-// break;
+ break;
+ case 'n':
+ case 't':
+ get_white_space(b, e, err, ct);
+ break;
 // case 'p':
-// that_.get_am_pm(tm->tm_hour, b, e, err, ct);
-// break;
-// case 'r':
-// {
-// const char_type fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
-// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
-// }
-// break;
-// case 'R':
-// {
-// const char_type fm[] = {'%', 'H', ':', '%', 'M'};
-// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
-// }
-// break;
+// get_am_pm(tm->tm_hour, b, e, err, ct);
+// break;
+ case 'r':
+ {
+ const char_type fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
+ b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+ }
+ break;
+ case 'R':
+ {
+ const char_type fm[] = {'%', 'H', ':', '%', 'M'};
+ b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+ }
+ break;
             case 'S':
               get_second(tm->tm_sec, b, e, err, ct);
- break;
-// case 'T':
-// {
-// const char_type fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
-// b = that_.get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
-// }
-// break;
+ break;
+ case 'T':
+ {
+ const char_type fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+ b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
+ }
+ break;
 // case 'w':
-// that_.get_weekday(tm->tm_wday, b, e, err, ct);
-// break;
+// get_weekday(tm->tm_wday, b, e, err, ct);
+// break;
 // case 'x':
-// return that_.get_date(b, e, iob, err, tm);
+// return get_date(b, e, iob, err, tm);
 // case 'X':
-// {
-// const string_type& fm = this->X();
+// {
+// const string_type& fm = X();
 // b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
-// }
-// break;
+// }
+// break;
 // case 'y':
-// that_.get_year(tm->tm_year, b, e, err, ct);
+// get_year(tm->tm_year, b, e, err, ct);
                 break;
             case 'Y':
               get_year4(tm->tm_year, b, e, err, ct);
- //std::cerr << "tm_year= "<< tm->tm_year << std::endl;
- break;
-// case '%':
-// that_.get_percent(b, e, err, ct);
-// break;
+ break;
+ case '%':
+ get_percent(b, e, err, ct);
+ break;
             default:
                 err |= std::ios_base::failbit;
             }
@@ -602,24 +689,19 @@
     std::basic_istream<CharT, Traits>&
     operator>>(std::basic_istream<CharT, Traits>& is, time_point<Clock, Duration>& tp)
     {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       std::ios_base::iostate err = std::ios_base::goodbit;
 
       BOOST_TRY
       {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         typename std::basic_istream<CharT, Traits>::sentry ipfx(is);
         if (bool(ipfx))
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           if (!std::has_facet<time_point_get<CharT> >(is.getloc()))
           {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
             time_point_get<CharT> ().get(is, std::istreambuf_iterator<CharT, Traits>(), is, err, tp);
           }
           else
           {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
             std::use_facet<time_point_get<CharT> >(is.getloc()).get(is, std::istreambuf_iterator<CharT, Traits>(), is,
                 err, tp);
           }
@@ -627,26 +709,20 @@
       }
       BOOST_CATCH (...)
       {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         bool flag = false;
         BOOST_TRY
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           is.setstate(std::ios_base::failbit);
         }
         BOOST_CATCH (std::ios_base::failure )
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           flag = true;
         }
         BOOST_CATCH_END
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         if (flag) throw;
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       }
       BOOST_CATCH_END
       if (err) is.setstate(err);
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       return is;
     }
 
@@ -747,19 +823,10 @@
        { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }
      };
 
- //tm->tm_year=0;
- //tm->tm_mon=0;
- //tm->tm_mday=0;
- //tm->tm_hour=0;
- //tm->tm_min=0;
- //tm->tm_sec=0;
-
      const time_t seconds_in_day = 3600 * 24;
      int32_t days_since_epoch = static_cast<int32_t>(*t / seconds_in_day);
      int32_t hms = static_cast<int32_t>(*t - seconds_in_day*days_since_epoch);
      if (hms < 0) {
- //std::cout << "days_since_epoch "<< days_since_epoch << std::endl;
- //std::cout << "hms "<< hms << std::endl;
        days_since_epoch-=1;
        hms = seconds_in_day+hms;
      }
@@ -783,21 +850,11 @@
        tm->tm_mday = doy - days_in_year_before[leap][day_of_year_month[leap][doy] - 1];
 
 
- //std::cout << "days_since_epoch "<< days_since_epoch << std::endl;
- //std::cout << "hms "<< hms << std::endl;
      tm->tm_hour = hms / 3600;
      const int ms = hms % 3600;
      tm->tm_min = ms / 60;
      tm->tm_sec = ms % 60;
 
- //std::cout << "t " << *t << std::endl;
- //std::cout << "year " << tm->tm_year << std::endl;
- //std::cout << "month " << tm->tm_mon << std::endl;
- //std::cout << "day " << tm->tm_mday << std::endl;
-// std::cout << "hour " << tm->tm_hour << std::endl;
-// std::cout << "min " << tm->tm_min << std::endl;
-// std::cout << "sec " << tm->tm_sec << std::endl;
-
      return tm;
    }
 
@@ -810,15 +867,12 @@
     std::basic_ostream<CharT, Traits>&
     operator<<(std::basic_ostream<CharT, Traits>& os, const time_point<system_clock, Duration>& tp)
     {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       typename std::basic_ostream<CharT, Traits>::sentry ok(os);
       if (bool(ok))
       {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         bool failed = false;
         BOOST_TRY
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
           std::basic_string<CharT> fmt = get_time_fmt<CharT> (os);
@@ -831,7 +885,6 @@
           std::tm tm;
           if (tz == timezone::local)
           {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
 #if defined BOOST_WINDOWS && ! defined(__CYGWIN__)
             std::tm *tmp = 0;
             if ((tmp=localtime(&t)) == 0)
@@ -844,7 +897,6 @@
           }
           else
           {
- //std::cerr << __FILE__ << "[" << __LINE__ << "] "<< t << std::endl;
 #if BOOST_CHRONO_INTERNAL_GMTIME
             if (detail::internal_gmtime(&t, &tm) == 0) failed = true;
 
@@ -859,14 +911,11 @@
 #endif
 
           }
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           if (!failed)
           {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
             const std::time_put<CharT>& tpf = std::use_facet<std::time_put<CharT> >(loc);
             if (pb == pe)
             {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
               CharT pattern[] =
               { '%', 'Y', '-', '%', 'm', '-', '%', 'd', ' ', '%', 'H', ':', '%', 'M', ':' };
               pb = pattern;
@@ -874,34 +923,23 @@
               failed = tpf.put(os, os, os.fill(), &tm, pb, pe).failed();
               if (!failed)
               {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 duration<double> d = tp - system_clock::from_time_t(t) + seconds(tm.tm_sec);
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 if (d.count() < 10) os << CharT('0');
                 //if (! os.good()) {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 // throw "exception";
                 //}
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 std::ios::fmtflags flgs = os.flags();
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 os.setf(std::ios::fixed, std::ios::floatfield);
                 //if (! os.good()) {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 //throw "exception";
                 //}
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< " " << d.count() << std::endl;
                 os << d.count();
                 //if (! os.good()) {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 //throw "exception";
                 //}
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< " " << d.count() << std::endl;
                 os.flags(flgs);
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                 if (tz == timezone::local)
                 {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                   CharT sub_pattern[] =
                   { ' ', '%', 'z' };
                   pb = sub_pattern;
@@ -910,35 +948,28 @@
                 }
                 else
                 {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
                   CharT sub_pattern[] =
                   { ' ', '+', '0', '0', '0', '0', 0 };
                   os << sub_pattern;
                 }
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
               }
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
             }
             else
             {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
               failed = tpf.put(os, os, os.fill(), &tm, pb, pe).failed();
             }
           }
         }
         BOOST_CATCH (...)
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           failed = true;
         }
         BOOST_CATCH_END
         if (failed)
         {
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           os.setstate(std::ios_base::failbit | std::ios_base::badbit);
         }
       }
- //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       return os;
     }
 #endif
@@ -1028,6 +1059,12 @@
           const std::time_get<CharT>& tg = std::use_facet<std::time_get<CharT> >(loc);
           const std::ctype<CharT>& ct = std::use_facet<std::ctype<CharT> >(loc);
           tm tm; // {0}
+ tm.tm_year=0;
+ tm.tm_mon=0;
+ tm.tm_mday=0;
+ tm.tm_hour=0;
+ tm.tm_min=0;
+ tm.tm_sec=0;
           typedef std::istreambuf_iterator<CharT, Traits> It;
           if (pb == pe)
           {
@@ -1035,7 +1072,7 @@
             { '%', 'Y', '-', '%', 'm', '-', '%', 'd', ' ', '%', 'H', ':', '%', 'M', ':' };
             pb = pattern;
             pe = pb + sizeof (pattern) / sizeof(CharT);
- tm.tm_sec=0;
+
 #if defined BOOST_CHRONO_USES_INTERNAL_TIME_GET
             const detail::time_get<CharT>& dtg(tg);
             dtg.get(is, 0, is, err, &tm, pb, pe);
@@ -1051,7 +1088,6 @@
               err |= std::ios_base::failbit;
               goto exit;
             }
- //std::cerr << "sec= "<< sec << std::endl;
             It i(is);
             It eof;
             c = *i;
@@ -1061,7 +1097,6 @@
               goto exit;
             }
             minutes min = detail::extract_z(i, eof, err, ct);
- //std::cerr << "min= "<< min.count() << std::endl;
 
             if (err & std::ios_base::failbit) goto exit;
             time_t t;

Modified: trunk/libs/chrono/test/io/time_point_input.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_input.cpp Sun Jul 7 11:29:01 2013 (r84972)
+++ trunk/libs/chrono/test/io/time_point_input.cpp 2013-07-07 12:08:54 EDT (Sun, 07 Jul 2013) (r84973)
@@ -38,6 +38,25 @@
   std::cout << "Obtained= " << boost::chrono::duration_cast<boost::chrono::nanoseconds>(tp.time_since_epoch()).count() << std::endl;
   BOOST_TEST( (tp == boost::chrono::time_point<Clock, D>(res)));
 }
+
+template <typename D>
+void test_good_utc_fmt_system_clock(std::string str, std::string fmt, D res)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::istringstream in(str);
+ boost::chrono::time_point<Clock, D> tp;
+ in >> time_fmt(boost::chrono::timezone::utc, fmt);
+ in >> tp;
+ BOOST_TEST(in.eof());
+ BOOST_TEST(!in.fail());
+ std::cout << "Input= " << str << std::endl;
+ std::cout << "Expected= " << boost::chrono::time_point<Clock, D>(res) << std::endl;
+ std::cout << "Obtained= " << tp << std::endl;
+ std::cout << "Expected= " << boost::chrono::duration_cast<boost::chrono::nanoseconds>(boost::chrono::time_point<Clock, D>(res).time_since_epoch()).count() << std::endl;
+ std::cout << "Obtained= " << boost::chrono::duration_cast<boost::chrono::nanoseconds>(tp.time_since_epoch()).count() << std::endl;
+ BOOST_TEST_EQ( tp , (boost::chrono::time_point<Clock, D>(res)));
+}
 #endif
 template <typename Clock, typename D>
 void test_fail(const char* str, D)
@@ -131,6 +150,13 @@
   test_good_system_clock ("1970-01-01 00:08:20.000000 +0000", duration<boost::int_least64_t, deci> (5000));
   test_good_system_clock ("1970-01-01 00:02:46.666667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (5000));
 
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%F %H:%M:%S", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02", "%Y-%m-%d %H", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02", "%F %H", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2));
+
 
 // test_fail<Clock> ("3001 ms", seconds(3));
 // test_fail_epoch<Clock> ("3001 ms", seconds(3));

Modified: trunk/libs/chrono/test/io/time_point_output.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_output.cpp Sun Jul 7 11:29:01 2013 (r84972)
+++ trunk/libs/chrono/test/io/time_point_output.cpp 2013-07-07 12:08:54 EDT (Sun, 07 Jul 2013) (r84973)
@@ -67,6 +67,20 @@
   BOOST_TEST( (out.str() == std::string(str) ));
 }
 
+template <typename D>
+void test_good_utc_fmt_system_clock(const char* str, const char* fmt, D d)
+{
+ typedef boost::chrono::system_clock Clock;
+
+ std::ostringstream out;
+ boost::chrono::time_point<Clock, D> tp(d);
+ out << time_fmt(boost::chrono::timezone::utc, fmt) << tp;
+ BOOST_TEST(out.good());
+ std::cout << "Expected= " << str << std::endl;
+ std::cout << "Obtained= " << out.str() << std::endl;
+ BOOST_TEST( (out.str() == std::string(str) ));
+}
+
 template<typename Clock, typename D>
 void test_good(const char* str, D d, boost::chrono::duration_style style)
 {
@@ -156,6 +170,13 @@
   test_good_symbol_system_clock("1970-01-01 00:00:00.000000 +0000", nanoseconds(2));
   test_good_symbol_system_clock("1970-01-01 00:00:00.200000 +0000", duration<boost::int_least64_t, deci> (2));
   test_good_symbol_system_clock("1970-01-01 00:00:00.066667 +0000", duration<boost::int_least64_t, ratio<1, 30> > (2));
+
+ test_good_utc_fmt_system_clock("1970-01-01 02:00:00", "%Y-%m-%d %H:%M:%S", hours(2));
+ test_good_utc_fmt_system_clock("1970-01-01 02", "%Y-%m-%d %H", hours(2));
+
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00:00", "%Y-%m-%d %T", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00", "%Y-%m-%d %R", hours(2));
+
 }
 
 void test_gmtime(std::time_t t)


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