|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85423 - in trunk: boost/chrono/io libs/chrono/test libs/chrono/test/io
From: vicente.botet_at_[hidden]
Date: 2013-08-22 12:22:53
Author: viboes
Date: 2013-08-22 12:22:53 EDT (Thu, 22 Aug 2013)
New Revision: 85423
URL: http://svn.boost.org/trac/boost/changeset/85423
Log:
Chrono: Support more flags on IO.
Text files modified:
trunk/boost/chrono/io/time_point_io.hpp | 75 +++++++++++++++++++--------------------
trunk/libs/chrono/test/io/time_point_input.cpp | 2 +
trunk/libs/chrono/test/io/time_point_output.cpp | 4 +
trunk/libs/chrono/test/test_7868.cpp | 5 ++
4 files changed, 47 insertions(+), 39 deletions(-)
Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp Thu Aug 22 12:20:35 2013 (r85422)
+++ trunk/boost/chrono/io/time_point_io.hpp 2013-08-22 12:22:53 EDT (Thu, 22 Aug 2013) (r85423)
@@ -218,32 +218,20 @@
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;
+ get_weekday(int& w,
+ 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, 1);
+ if (!(err & std::ios_base::failbit) && t <= 6)
+ w = t;
+ else
+ err |= std::ios_base::failbit;
}
+#if 0
void
get_am_pm(int& h,
@@ -278,19 +266,27 @@
switch (fmt)
{
-// case 'a':
-// case 'A':
-// get_weekdayname(tm->tm_wday, b, e, err, ct);
-// break;
-// case 'b':
-// case 'B':
-// case 'h':
-// get_monthname(tm->tm_mon, b, e, err, ct);
-// break;
+ case 'a':
+ case 'A':
+ {
+ std::tm tm2;
+ that_.get_weekday(b, e, iob, err, &tm2);
+ //tm->tm_wday = tm2.tm_wday;
+ }
+ break;
+ case 'b':
+ case 'B':
+ case 'h':
+ {
+ std::tm tm2;
+ that_.get_monthname(b, e, iob, err, &tm2);
+ //tm->tm_mon = tm2.tm_mon;
+ }
+ break;
// case 'c':
// {
// const string_type& fm = c();
-// b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
+// b = get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
// }
// break;
case 'd':
@@ -352,12 +348,15 @@
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
-// case 'w':
-// get_weekday(tm->tm_wday, b, e, err, ct);
-// break;
-// case 'x':
-// return get_date(b, e, iob, err, tm);
+ case 'w':
+ {
+ get_weekday(tm->tm_wday, b, e, err, ct);
+ }
+ break;
+ case 'x':
+ return that_.get_date(b, e, iob, err, tm);
// case 'X':
+// return that_.get_time(b, e, iob, err, tm);
// {
// const string_type& fm = X();
// b = that_.get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
Modified: trunk/libs/chrono/test/io/time_point_input.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_input.cpp Thu Aug 22 12:20:35 2013 (r85422)
+++ trunk/libs/chrono/test/io/time_point_input.cpp 2013-08-22 12:22:53 EDT (Thu, 22 Aug 2013) (r85423)
@@ -156,6 +156,8 @@
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_good_utc_fmt_system_clock ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2));
+ //test_good_utc_fmt_system_clock ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2));
// test_fail<Clock> ("3001 ms", seconds(3));
Modified: trunk/libs/chrono/test/io/time_point_output.cpp
==============================================================================
--- trunk/libs/chrono/test/io/time_point_output.cpp Thu Aug 22 12:20:35 2013 (r85422)
+++ trunk/libs/chrono/test/io/time_point_output.cpp 2013-08-22 12:22:53 EDT (Thu, 22 Aug 2013) (r85423)
@@ -78,7 +78,7 @@
BOOST_TEST(out.good());
std::cout << "Expected= " << str << std::endl;
std::cout << "Obtained= " << out.str() << std::endl;
- BOOST_TEST( (out.str() == std::string(str) ));
+ BOOST_TEST_EQ( out.str() , std::string(str) );
}
template<typename Clock, typename D>
@@ -176,6 +176,8 @@
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_good_utc_fmt_system_clock ("% 1970-01-01 02:00", "%% %Y-%m-%d %R", hours(2));
+ test_good_utc_fmt_system_clock ("1970-01-01 02:00 Thursday January", "%Y-%m-%d %R %A %B", hours(2));
}
Modified: trunk/libs/chrono/test/test_7868.cpp
==============================================================================
--- trunk/libs/chrono/test/test_7868.cpp Thu Aug 22 12:20:35 2013 (r85422)
+++ trunk/libs/chrono/test/test_7868.cpp 2013-08-22 12:22:53 EDT (Thu, 22 Aug 2013) (r85423)
@@ -1,3 +1,8 @@
+// Copyright 2013 Vicente J. Botet Escriba
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+// See http://www.boost.org/libs/chrono for documentation.
+
#define BOOST_CHRONO_VERSION 2
//#define BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT 1
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