1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// NetBSD does not support LC_TIME at the moment
// XFAIL: netbsd
// REQUIRES: locale.en_US.UTF-8
// REQUIRES: locale.fr_FR.UTF-8
// <locale>
// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
// class time_put_byname
// : public time_put<CharT, OutputIterator>
// {
// public:
// explicit time_put_byname(const char* nm, size_t refs = 0);
// explicit time_put_byname(const string& nm, size_t refs = 0);
//
// protected:
// ~time_put_byname();
// };
// TODO: investigation needed
// XFAIL: linux-gnu
#include <locale>
#include <cassert>
#include "test_iterators.h"
#include "platform_support.h" // locale name macros
typedef std::time_put_byname<char, output_iterator<char*> > F;
class my_facet
: public F
{
public:
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {}
};
int main()
{
char str[200];
output_iterator<char*> iter;
tm t;
t.tm_sec = 6;
t.tm_min = 3;
t.tm_hour = 13;
t.tm_mday = 2;
t.tm_mon = 4;
t.tm_year = 109;
t.tm_wday = 6;
t.tm_yday = -1;
t.tm_isdst = 1;
std::ios ios(0);
{
const my_facet f(LOCALE_en_US_UTF_8, 1);
std::string pat("Today is %A which is abbreviated %a.");
iter = f.put(output_iterator<char*>(str), ios, '*', &t,
pat.data(), pat.data() + pat.size());
std::string ex(str, iter.base());
assert(ex == "Today is Saturday which is abbreviated Sat.");
}
{
const my_facet f(LOCALE_fr_FR_UTF_8, 1);
std::string pat("Today is %A which is abbreviated %a.");
iter = f.put(output_iterator<char*>(str), ios, '*', &t,
pat.data(), pat.data() + pat.size());
std::string ex(str, iter.base());
assert((ex == "Today is Samedi which is abbreviated Sam.")||
(ex == "Today is samedi which is abbreviated sam." ));
}
}
|