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 //===----------------------------------------------------------------------===//
12 // template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
17 #include "platform_support.h" // locale name macros
19 template <class CharT>
21 : public std::basic_streambuf<CharT>
23 typedef std::basic_string<CharT> string_type;
24 typedef std::basic_streambuf<CharT> base;
30 testbuf(const string_type& str)
33 base::setg(const_cast<CharT*>(str_.data()),
34 const_cast<CharT*>(str_.data()),
35 const_cast<CharT*>(str_.data()) + str_.size());
42 testbuf<char> sb(" Sat Dec 31 23:55:59 2061");
44 is.imbue(std::locale(LOCALE_en_US_UTF_8));
46 is >> std::get_time(&t, "%a %b %d %H:%M:%S %Y");
47 assert(t.tm_sec == 59);
48 assert(t.tm_min == 55);
49 assert(t.tm_hour == 23);
50 assert(t.tm_mday == 31);
51 assert(t.tm_mon == 11);
52 assert(t.tm_year == 161);
53 assert(t.tm_wday == 6);
58 testbuf<wchar_t> sb(L" Sat Dec 31 23:55:59 2061");
59 std::wistream is(&sb);
60 is.imbue(std::locale(LOCALE_en_US_UTF_8));
62 is >> std::get_time(&t, L"%a %b %d %H:%M:%S %Y");
63 assert(t.tm_sec == 59);
64 assert(t.tm_min == 55);
65 assert(t.tm_hour == 23);
66 assert(t.tm_mday == 31);
67 assert(t.tm_mon == 11);
68 assert(t.tm_year == 161);
69 assert(t.tm_wday == 6);