1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // REQUIRES: locale.en_US.UTF-8
13 // template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
19 #include "test_macros.h"
20 #include "platform_support.h" // locale name macros
22 template <class CharT
>
24 : public std::basic_streambuf
<CharT
>
26 typedef std::basic_string
<CharT
> string_type
;
27 typedef std::basic_streambuf
<CharT
> base
;
33 testbuf(const string_type
& str
)
36 base::setg(const_cast<CharT
*>(str_
.data()),
37 const_cast<CharT
*>(str_
.data()),
38 const_cast<CharT
*>(str_
.data()) + str_
.size());
45 testbuf
<char> sb(" Sat Dec 31 23:55:59 2061");
47 is
.imbue(std::locale(LOCALE_en_US_UTF_8
));
49 is
>> std::get_time(&t
, "%a %b %d %H:%M:%S %Y");
50 assert(t
.tm_sec
== 59);
51 assert(t
.tm_min
== 55);
52 assert(t
.tm_hour
== 23);
53 assert(t
.tm_mday
== 31);
54 assert(t
.tm_mon
== 11);
55 assert(t
.tm_year
== 161);
56 assert(t
.tm_wday
== 6);
60 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
62 testbuf
<wchar_t> sb(L
" Sat Dec 31 23:55:59 2061");
63 std::wistream
is(&sb
);
64 is
.imbue(std::locale(LOCALE_en_US_UTF_8
));
66 is
>> std::get_time(&t
, L
"%a %b %d %H:%M:%S %Y");
67 assert(t
.tm_sec
== 59);
68 assert(t
.tm_min
== 55);
69 assert(t
.tm_hour
== 23);
70 assert(t
.tm_mday
== 31);
71 assert(t
.tm_mon
== 11);
72 assert(t
.tm_year
== 161);
73 assert(t
.tm_wday
== 6);