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
11 // REQUIRES: locale.fr_FR.UTF-8
15 // template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
16 // class time_put_byname
17 // : public time_put<CharT, OutputIterator>
20 // explicit time_put_byname(const char* nm, size_t refs = 0);
21 // explicit time_put_byname(const string& nm, size_t refs = 0);
24 // ~time_put_byname();
29 #include "test_iterators.h"
31 #include "platform_support.h" // locale name macros
33 typedef std::time_put_byname<char, output_iterator<char*> > F;
39 explicit my_facet(const std::string& nm, std::size_t refs = 0)
46 output_iterator<char*> iter;
59 const my_facet f(LOCALE_en_US_UTF_8, 1);
60 std::string pat("Today is %A which is abbreviated %a.");
61 iter = f.put(output_iterator<char*>(str), ios, '*', &t,
62 pat.data(), pat.data() + pat.size());
63 std::string ex(str, iter.base());
64 assert(ex == "Today is Saturday which is abbreviated Sat.");
67 const my_facet f(LOCALE_fr_FR_UTF_8, 1);
68 std::string pat("Today is %A which is abbreviated %a.");
69 iter = f.put(output_iterator<char*>(str), ios, '*', &t,
70 pat.data(), pat.data() + pat.size());
71 std::string ex(str, iter.base());
72 assert((ex == "Today is Samedi which is abbreviated Sam.")||
73 (ex == "Today is samedi which is abbreviated sam." ));