1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: locale.en_US.UTF-8
14 // template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
19 #include "platform_support.h" // locale name macros
21 template <class CharT>
23 : public std::basic_streambuf<CharT>
25 typedef std::basic_streambuf<CharT> base;
26 std::basic_string<CharT> str_;
32 std::basic_string<CharT> str() const
33 {return std::basic_string<CharT>(base::pbase(), base::pptr());}
37 virtual typename base::int_type
38 overflow(typename base::int_type __c = base::traits_type::eof())
40 if (__c != base::traits_type::eof())
44 str_.resize(str_.capacity());
45 base::setp(const_cast<CharT*>(str_.data()),
46 const_cast<CharT*>(str_.data() + str_.size()));
58 os.imbue(std::locale(LOCALE_en_US_UTF_8));
68 os << std::put_time(&t, "%a %b %d %H:%M:%S %Y");
69 assert(sb.str() == "Sat Dec 31 23:55:59 2061");
73 std::wostream os(&sb);
74 os.imbue(std::locale(LOCALE_en_US_UTF_8));
83 os << std::put_time(&t, L"%a %b %d %H:%M:%S %Y");
84 assert(sb.str() == L"Sat Dec 31 23:55:59 2061");