public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/3] libstdc++: Add put_time support.
       [not found] <e10a43fd7a4e1483232e786c6effe00757da1804.1397596544.git.ruediger@c-plusplus.de>
@ 2014-04-15 21:20 ` Rüdiger Sonderfeld
  2014-10-13 12:10   ` Jonathan Wakely
  2014-04-15 21:24 ` [PATCH 3/3] libstdc++: Add get_time support Rüdiger Sonderfeld
  1 sibling, 1 reply; 7+ messages in thread
From: Rüdiger Sonderfeld @ 2014-04-15 21:20 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Described in [ext.manip].

* libstdc++-v3/include/std/iomanip (_Put_time): New struct.
  (put_time): New manipulator.
  (operator<<): New overloaded function.
* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc:
  New file.
---
 libstdc++-v3/include/std/iomanip                   | 56 ++++++++++++++++++++++
 .../27_io/manipulators/extended/put_time/char/1.cc | 44 +++++++++++++++++
 .../27_io/manipulators/extended/put_time/char/2.cc | 47 ++++++++++++++++++
 .../manipulators/extended/put_time/wchar_t/1.cc    | 44 +++++++++++++++++
 .../manipulators/extended/put_time/wchar_t/2.cc    | 47 ++++++++++++++++++
 5 files changed, 238 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc

diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index 73822db..03ca784 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -334,6 +334,62 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __os; 
     }
 
+
+
+  template<typename _CharT>
+    struct _Put_time {
+    const std::tm* _M_tmb;
+    const _CharT* _M_fmt;
+  };
+
+  /**
+   *  @brief  Extended manipulator for formatting time.
+   *
+   *  This manipulator uses time_put::put for format time.
+   *  [ext.manip]
+   *
+   *  @param __tmb  struct tm time data to format.
+   *  @param __fmt  format string.
+   */
+  template<typename _CharT>
+    inline _Put_time<_CharT>
+    put_time(const std::tm* __tmb, const _CharT* __fmt)
+    { return { __tmb, __fmt }; }
+
+  template<typename _CharT, typename _Traits>
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f)
+    {
+      typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
+      if (__cerb)
+        {
+          ios_base::iostate __err = ios_base::goodbit;
+          __try
+            {
+              typedef ostreambuf_iterator<_CharT, _Traits>   _Iter;
+              typedef time_put<_CharT, _Iter>                _TimePut;
+
+              const _CharT* const __fmt_end = __f._M_fmt +
+                _Traits::length(__f._M_fmt);
+
+              const _TimePut& __mp = use_facet<_TimePut>(__os.getloc());
+              if (__mp.put(_Iter(__os.rdbuf()), __os, __os.fill(),
+                           __f._M_tmb, __f._M_fmt, __fmt_end).failed())
+                __err |= ios_base::badbit;
+            }
+          __catch(__cxxabiv1::__forced_unwind&)
+            {
+              __os._M_setstate(ios_base::badbit);
+              __throw_exception_again;
+            }
+          __catch(...)
+            { __os._M_setstate(ios_base::badbit); }
+          if (__err)
+            __os.setstate(__err);
+        }
+      return __os;
+    }
+
 #if __cplusplus > 201103L
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc
new file mode 100644
index 0000000..76e64ea
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc
@@ -0,0 +1,44 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  ostringstream oss;
+  oss.imbue(loc_c);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, "%a %Y");
+  VERIFY(oss.str() == "Sun 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc
new file mode 100644
index 0000000..c3d492c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc
@@ -0,0 +1,47 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  ostringstream oss;
+  oss.imbue(loc_de);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, "%a %Y");
+  VERIFY(oss.str() == "Son 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc
new file mode 100644
index 0000000..3b5d5fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc
@@ -0,0 +1,44 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  wostringstream oss;
+  oss.imbue(loc_c);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, L"%a %Y");
+  VERIFY(oss.str() == L"Sun 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc
new file mode 100644
index 0000000..fff3e4f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc
@@ -0,0 +1,47 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  wostringstream oss;
+  oss.imbue(loc_de);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, L"%a %Y");
+  VERIFY(oss.str() == L"Son 1971");
+}
+
+int main()
+{
+  test01();
+}
-- 
1.9.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/3] libstdc++: Add get_time support.
       [not found] <e10a43fd7a4e1483232e786c6effe00757da1804.1397596544.git.ruediger@c-plusplus.de>
  2014-04-15 21:20 ` [PATCH 2/3] libstdc++: Add put_time support Rüdiger Sonderfeld
@ 2014-04-15 21:24 ` Rüdiger Sonderfeld
  2014-12-22 13:53   ` Jonathan Wakely
  1 sibling, 1 reply; 7+ messages in thread
From: Rüdiger Sonderfeld @ 2014-04-15 21:24 UTC (permalink / raw)
  To: libstdc++, gcc-patches

* libstdc++-v3/include/std/iomanip (_Get_time): New struct.
  (get_time): New manipulator [ext.manip].
  (operator>>): New overloaded function.
* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc:
* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc:
  New file.
---
 libstdc++-v3/include/std/iomanip                   | 54 ++++++++++++++++++++++
 .../27_io/manipulators/extended/get_time/char/1.cc | 48 +++++++++++++++++++
 .../27_io/manipulators/extended/get_time/char/2.cc | 49 ++++++++++++++++++++
 .../manipulators/extended/get_time/wchar_t/1.cc    | 48 +++++++++++++++++++
 .../manipulators/extended/get_time/wchar_t/2.cc    | 50 ++++++++++++++++++++
 5 files changed, 249 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc
 create mode 100644 libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc

diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index 03ca784..a6d1b23 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -390,6 +390,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __os;
     }
 
+
+  template<typename _CharT>
+    struct _Get_time {
+         std::tm*  _M_tmb;
+    const _CharT*  _M_fmt;
+  };
+
+  /**
+   *  @brief  Extended manipulator for extracting time.
+   *
+   *  This manipulator uses time_get::get to extract time.
+   *  [ext.manip]
+   *
+   *  @param __tmb  struct to extract the time data to.
+   *  @param __fmt  format string.
+   */
+  template<typename _CharT>
+    inline _Get_time<_CharT>
+    get_time(std::tm* __tmb, const _CharT* __fmt)
+    { return { __tmb, __fmt }; }
+
+  template<typename _CharT, typename _Traits>
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f)
+    {
+      typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
+      if (__cerb)
+        {
+          ios_base::iostate __err = ios_base::goodbit;
+          __try
+            {
+              typedef istreambuf_iterator<_CharT, _Traits>   _Iter;
+              typedef time_get<_CharT, _Iter>                _TimeGet;
+
+              const _CharT* const __fmt_end = __f._M_fmt +
+                _Traits::length(__f._M_fmt);
+
+              const _TimeGet& __mg = use_facet<_TimeGet>(__is.getloc());
+              __mg.get(_Iter(__is.rdbuf()), _Iter(), __is,
+                       __err, __f._M_tmb, __f._M_fmt, __fmt_end);
+            }
+          __catch(__cxxabiv1::__forced_unwind&)
+            {
+              __is._M_setstate(ios_base::badbit);
+              __throw_exception_again;
+            }
+          __catch(...)
+            { __is._M_setstate(ios_base::badbit); }
+          if (__err)
+            __is.setstate(__err);
+        }
+      return __is;
+    }
+
 #if __cplusplus > 201103L
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc
new file mode 100644
index 0000000..26af16f
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc
@@ -0,0 +1,48 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  istringstream iss;
+  iss.imbue(loc_c);
+  iss.str("12:01:30  1971");
+  tm time1;
+  iss >> get_time(&time1, "%H:%M:%S %Y");
+  VERIFY(time1.tm_hour == 12);
+  VERIFY(time1.tm_min == 1);
+  VERIFY(time1.tm_sec == 30);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
new file mode 100644
index 0000000..fcba0c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
@@ -0,0 +1,49 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  istringstream iss;
+  iss.imbue(loc_de);
+  iss.str("Di 1971");
+  tm time1;
+  iss >> get_time(&time1, "%a %Y");
+  VERIFY(time1.tm_wday == 2);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc
new file mode 100644
index 0000000..a096a72
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc
@@ -0,0 +1,48 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  wistringstream iss;
+  iss.imbue(loc_c);
+  iss.str(L"12:01:30  1971");
+  tm time1;
+  iss >> get_time(&time1, L"%H:%M:%S %Y");
+  VERIFY(time1.tm_hour = 12);
+  VERIFY(time1.tm_min = 1);
+  VERIFY(time1.tm_sec == 30);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc
new file mode 100644
index 0000000..4d28498
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc
@@ -0,0 +1,50 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 Rüdiger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  wistringstream iss;
+  iss.imbue(loc_de);
+  iss.str(L"Montag 1971");
+  tm time1;
+  iss >> get_time(&time1, L"%A %Y");
+  VERIFY(time1.tm_wday == 1);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
-- 
1.9.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] libstdc++: Add put_time support.
  2014-04-15 21:20 ` [PATCH 2/3] libstdc++: Add put_time support Rüdiger Sonderfeld
@ 2014-10-13 12:10   ` Jonathan Wakely
  2014-10-13 15:33     ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2014-10-13 12:10 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: libstdc++, gcc-patches

On 15/04/14 23:20 +0200, Rüdiger Sonderfeld wrote:
>Described in [ext.manip].
>
>* libstdc++-v3/include/std/iomanip (_Put_time): New struct.
>  (put_time): New manipulator.
>  (operator<<): New overloaded function.
>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc:
>  New file.

The 27_io/manipulators/extended/put_time/char/2.cc and
27_io/manipulators/extended/put_time/wchar_t/2.cc tests fail for me.

i2.exe: /home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:41: void test01(): Assertion `oss.str() == "Son 1971"' failed.
FAIL: 27_io/manipulators/extended/put_time/char/2.cc execution test

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] libstdc++: Add put_time support.
  2014-10-13 12:10   ` Jonathan Wakely
@ 2014-10-13 15:33     ` Jonathan Wakely
  2014-10-14 17:07       ` Jonathan Wakely
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2014-10-13 15:33 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: libstdc++, gcc-patches

On 13/10/14 13:08 +0100, Jonathan Wakely wrote:
>On 15/04/14 23:20 +0200, Rüdiger Sonderfeld wrote:
>>Described in [ext.manip].
>>
>>* libstdc++-v3/include/std/iomanip (_Put_time): New struct.
>> (put_time): New manipulator.
>> (operator<<): New overloaded function.
>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc:
>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:
>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc:
>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc:
>> New file.
>
>The 27_io/manipulators/extended/put_time/char/2.cc and
>27_io/manipulators/extended/put_time/wchar_t/2.cc tests fail for me.
>
>i2.exe: /home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:41: void test01(): Assertion `oss.str() == "Son 1971"' failed.
>FAIL: 27_io/manipulators/extended/put_time/char/2.cc execution test

With my de_DE.utf8 locale the output is "So 1971" not "Son 1971".

$ LANG=de_DE.utf8 date +%a 
Mo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] libstdc++: Add put_time support.
  2014-10-13 15:33     ` Jonathan Wakely
@ 2014-10-14 17:07       ` Jonathan Wakely
  2014-10-14 18:25         ` Rüdiger Sonderfeld
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Wakely @ 2014-10-14 17:07 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

On 13/10/14 16:28 +0100, Jonathan Wakely wrote:
>On 13/10/14 13:08 +0100, Jonathan Wakely wrote:
>>On 15/04/14 23:20 +0200, Rüdiger Sonderfeld wrote:
>>>Described in [ext.manip].
>>>
>>>* libstdc++-v3/include/std/iomanip (_Put_time): New struct.
>>>(put_time): New manipulator.
>>>(operator<<): New overloaded function.
>>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc:
>>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:
>>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc:
>>>* libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc:
>>>New file.
>>
>>The 27_io/manipulators/extended/put_time/char/2.cc and
>>27_io/manipulators/extended/put_time/wchar_t/2.cc tests fail for me.
>>
>>i2.exe: /home/jwakely/src/gcc/gcc/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc:41: void test01(): Assertion `oss.str() == "Son 1971"' failed.
>>FAIL: 27_io/manipulators/extended/put_time/char/2.cc execution test
>
>With my de_DE.utf8 locale the output is "So 1971" not "Son 1971".
>
>$ LANG=de_DE.utf8 date +%a Mo

So let's just test the full name and not worry about how it's
abbreviated.

Tested x86_64-linux, committed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 9750 bytes --]

commit 4ae8f20e4924754d7fb7809730f5491dc6a74944
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 14 17:48:44 2014 +0100

    2014-10-14  R??diger Sonderfeld  <ruediger@c-plusplus.de>
    
    	PR libstdc++/54354
    	* include/std/iomanip (_Put_time): New struct.
    	(put_time): New manipulator.
    	(operator<<): New overloaded function.
    	* testsuite/27_io/manipulators/extended/put_time/char/1.cc: New.
    	* testsuite/27_io/manipulators/extended/put_time/char/2.cc: New.
    	* testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc: New.
    	* testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc: New.

diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index 9625d43..fce74c9 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -337,6 +337,61 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __os; 
     }
 
+  template<typename _CharT>
+    struct _Put_time
+    {
+      const std::tm* _M_tmb;
+      const _CharT* _M_fmt;
+    };
+
+  /**
+   *  @brief  Extended manipulator for formatting time.
+   *
+   *  This manipulator uses time_put::put to format time.
+   *  [ext.manip]
+   *
+   *  @param __tmb  struct tm time data to format.
+   *  @param __fmt  format string.
+   */
+  template<typename _CharT>
+    inline _Put_time<_CharT>
+    put_time(const std::tm* __tmb, const _CharT* __fmt)
+    { return { __tmb, __fmt }; }
+
+  template<typename _CharT, typename _Traits>
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_time<_CharT> __f)
+    {
+      typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
+      if (__cerb)
+        {
+          ios_base::iostate __err = ios_base::goodbit;
+          __try
+            {
+              typedef ostreambuf_iterator<_CharT, _Traits>   _Iter;
+              typedef time_put<_CharT, _Iter>                _TimePut;
+
+              const _CharT* const __fmt_end = __f._M_fmt +
+                _Traits::length(__f._M_fmt);
+
+              const _TimePut& __mp = use_facet<_TimePut>(__os.getloc());
+              if (__mp.put(_Iter(__os.rdbuf()), __os, __os.fill(),
+                           __f._M_tmb, __f._M_fmt, __fmt_end).failed())
+                __err |= ios_base::badbit;
+            }
+          __catch(__cxxabiv1::__forced_unwind&)
+            {
+              __os._M_setstate(ios_base::badbit);
+              __throw_exception_again;
+            }
+          __catch(...)
+            { __os._M_setstate(ios_base::badbit); }
+          if (__err)
+            __os.setstate(__err);
+        }
+      return __os;
+    }
+
 #if __cplusplus > 201103L
 
 #define __cpp_lib_quoted_string_io 201304
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc
new file mode 100644
index 0000000..76e64ea
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/1.cc
@@ -0,0 +1,44 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  ostringstream oss;
+  oss.imbue(loc_c);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, "%a %Y");
+  VERIFY(oss.str() == "Sun 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc
new file mode 100644
index 0000000..bc3a387
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/char/2.cc
@@ -0,0 +1,47 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  ostringstream oss;
+  oss.imbue(loc_de);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, "%A %Y");
+  VERIFY(oss.str() == "Sonntag 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc
new file mode 100644
index 0000000..3b5d5fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/1.cc
@@ -0,0 +1,44 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  wostringstream oss;
+  oss.imbue(loc_c);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, L"%a %Y");
+  VERIFY(oss.str() == L"Sun 1971");
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc
new file mode 100644
index 0000000..7dc90d0
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/put_time/wchar_t/2.cc
@@ -0,0 +1,47 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  wostringstream oss;
+  oss.imbue(loc_de);
+  const tm time1 = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
+  oss << put_time(&time1, L"%A %Y");
+  VERIFY(oss.str() == L"Sonntag 1971");
+}
+
+int main()
+{
+  test01();
+}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] libstdc++: Add put_time support.
  2014-10-14 17:07       ` Jonathan Wakely
@ 2014-10-14 18:25         ` Rüdiger Sonderfeld
  0 siblings, 0 replies; 7+ messages in thread
From: Rüdiger Sonderfeld @ 2014-10-14 18:25 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

On Tuesday 14 October 2014 18:01:59 Jonathan Wakely wrote:
> So let's just test the full name and not worry about how it's
> abbreviated.
> 
> Tested x86_64-linux, committed to trunk.

Sorry for causing the trouble.  I had it tested on my local machine.  Maybe 
the de_DE.utf8 locale is different.  Anyway testing for the full name is 
probably a better idea.  Thanks.

Regards,
Rüdiger.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] libstdc++: Add get_time support.
  2014-04-15 21:24 ` [PATCH 3/3] libstdc++: Add get_time support Rüdiger Sonderfeld
@ 2014-12-22 13:53   ` Jonathan Wakely
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Wakely @ 2014-12-22 13:53 UTC (permalink / raw)
  To: Rüdiger Sonderfeld; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

On 15/04/14 23:20 +0200, Rüdiger Sonderfeld wrote:
>* libstdc++-v3/include/std/iomanip (_Get_time): New struct.
>  (get_time): New manipulator [ext.manip].
>  (operator>>): New overloaded function.
>* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc:
>* libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc:
>  New file.

Committed as attached - thanks for the patches, after this there are
very few C++11 features missing from libstdc++!



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 9903 bytes --]

commit bec22aeacafd666944490aebc1afa007e0043f8f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 14 13:31:28 2014 +0100

    2014-12-22  R??diger Sonderfeld  <ruediger@c-plusplus.de>
    
    	PR libstdc++/54354
    	* include/std/iomanip (_Get_time): New struct.
    	(get_time): New manipulator.
    	(operator<<): New overloaded function.
    	* testsuite/27_io/manipulators/extended/get_time/char/1.cc: New.
    	* testsuite/27_io/manipulators/extended/get_time/char/2.cc: New.
    	* testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc: New.
    	* testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc: New.

diff --git a/libstdc++-v3/include/std/iomanip b/libstdc++-v3/include/std/iomanip
index fce74c9..080dae3 100644
--- a/libstdc++-v3/include/std/iomanip
+++ b/libstdc++-v3/include/std/iomanip
@@ -392,6 +392,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __os;
     }
 
+  template<typename _CharT>
+    struct _Get_time
+    {
+      std::tm*	    _M_tmb;
+      const _CharT* _M_fmt;
+    };
+
+  /**
+   *  @brief  Extended manipulator for extracting time.
+   *
+   *  This manipulator uses time_get::get to extract time.
+   *  [ext.manip]
+   *
+   *  @param __tmb  struct to extract the time data to.
+   *  @param __fmt  format string.
+   */
+  template<typename _CharT>
+    inline _Get_time<_CharT>
+    get_time(std::tm* __tmb, const _CharT* __fmt)
+    { return { __tmb, __fmt }; }
+
+  template<typename _CharT, typename _Traits>
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f)
+    {
+      typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
+      if (__cerb)
+        {
+          ios_base::iostate __err = ios_base::goodbit;
+          __try
+            {
+              typedef istreambuf_iterator<_CharT, _Traits>   _Iter;
+              typedef time_get<_CharT, _Iter>                _TimeGet;
+
+              const _CharT* const __fmt_end = __f._M_fmt +
+                _Traits::length(__f._M_fmt);
+
+              const _TimeGet& __mg = use_facet<_TimeGet>(__is.getloc());
+              __mg.get(_Iter(__is.rdbuf()), _Iter(), __is,
+                       __err, __f._M_tmb, __f._M_fmt, __fmt_end);
+            }
+          __catch(__cxxabiv1::__forced_unwind&)
+            {
+              __is._M_setstate(ios_base::badbit);
+              __throw_exception_again;
+            }
+          __catch(...)
+            { __is._M_setstate(ios_base::badbit); }
+          if (__err)
+            __is.setstate(__err);
+        }
+      return __is;
+    }
+
 #if __cplusplus > 201103L
 
 #define __cpp_lib_quoted_string_io 201304
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc
new file mode 100644
index 0000000..07f0111
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/1.cc
@@ -0,0 +1,49 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  istringstream iss;
+  iss.imbue(loc_c);
+  iss.str("12:01:30  1971");
+  tm time1;
+  iss >> get_time(&time1, "%H:%M:%S %Y");
+  VERIFY( static_cast<bool>(iss) );
+  VERIFY(time1.tm_hour == 12);
+  VERIFY(time1.tm_min == 1);
+  VERIFY(time1.tm_sec == 30);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
new file mode 100644
index 0000000..fcba0c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc
@@ -0,0 +1,49 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  istringstream iss;
+  iss.imbue(loc_de);
+  iss.str("Di 1971");
+  tm time1;
+  iss >> get_time(&time1, "%a %Y");
+  VERIFY(time1.tm_wday == 2);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc
new file mode 100644
index 0000000..ed0325a
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/1.cc
@@ -0,0 +1,49 @@
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  wistringstream iss;
+  iss.imbue(loc_c);
+  iss.str(L"12:01:30  1971");
+  tm time1;
+  iss >> get_time(&time1, L"%H:%M:%S %Y");
+  VERIFY( static_cast<bool>(iss) );
+  VERIFY(time1.tm_hour = 12);
+  VERIFY(time1.tm_min = 1);
+  VERIFY(time1.tm_sec == 30);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}
diff --git a/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc
new file mode 100644
index 0000000..4d28498
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/wchar_t/2.cc
@@ -0,0 +1,50 @@
+// { dg-require-namedlocale "de_DE.utf8" }
+// { dg-options " -std=gnu++11 " }
+
+// 2014-04-14 R??diger Sonderfeld  <ruediger@c-plusplus.de>
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 27.7.5. (C++11) Extended manipulators [ext.manip]: put_time
+
+#include <locale>
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  bool test __attribute__((unused)) = true;
+  locale loc_c = locale::classic();
+  locale loc_de = locale("de_DE.utf8");
+  VERIFY( loc_de != loc_c );
+  wistringstream iss;
+  iss.imbue(loc_de);
+  iss.str(L"Montag 1971");
+  tm time1;
+  iss >> get_time(&time1, L"%A %Y");
+  VERIFY(time1.tm_wday == 1);
+  VERIFY(time1.tm_year == 71);
+}
+
+int main()
+{
+  test01();
+}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-22 13:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <e10a43fd7a4e1483232e786c6effe00757da1804.1397596544.git.ruediger@c-plusplus.de>
2014-04-15 21:20 ` [PATCH 2/3] libstdc++: Add put_time support Rüdiger Sonderfeld
2014-10-13 12:10   ` Jonathan Wakely
2014-10-13 15:33     ` Jonathan Wakely
2014-10-14 17:07       ` Jonathan Wakely
2014-10-14 18:25         ` Rüdiger Sonderfeld
2014-04-15 21:24 ` [PATCH 3/3] libstdc++: Add get_time support Rüdiger Sonderfeld
2014-12-22 13:53   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).