1 // Copyright (C) 2004 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 #include <testsuite_hooks.h>
27 bool test __attribute__((unused)) = true;
28 locale l1 = __gnu_test::try_named_locale("de_DE");
29 locale l2 = __gnu_test::try_named_locale("es_ES");
31 const time_put<char> &tp = use_facet<time_put<char> >(l1);
36 tp.put(oss.rdbuf(), oss, ' ', &t, 'A');
37 string res = oss.str();
39 VERIFY( res == "domingo" );
44 // Two interpretations of the standard.
46 // 1 : time_get, time_put each have their own data internally
47 // use internal data for time and date specifics
48 // use getloc for ctype info
50 // 2 : time_get, time_put use the ios_base& argument and getloc to
51 // retrieve the necessary data.
52 // use getloc for ctype, time and date specifics
54 // It is my opinion that the language in the standard is sufficiently
55 // vague to permit both interpretations. In particular, the interface
56 // for time_get and time_put is based on strftime, which as
57 // POSIX notes is dependent on LC_TIME. The C++ standard, however,
58 // does not specify the equivalent mappings of LC_TIME to time_get and
62 The problems with the first approach, as above, are numerous.
64 1) Then locale usage and design for formatters and parers becomes
65 fragmented. On one side, num_put and money_put, and on the other,
66 time_put. This inconsistency is not useful.
68 2) The data structures for time and date formatting are the largest in
69 the locale library. Making time_put and time_get keep separate
70 copies is inefficient. (Note that time_put and time_get are in the
71 same locale::category).
76 22.2.5 - The time category [lib.category.time]
78 -1- Templates time_get<charT,InputIterator> and
79 time_put<charT,OutputIterator> provide date and time formatting and
80 parsing. All specifications of member functions for time_put and
81 time_get in the subclauses of lib.category.time only apply to the
82 instantiations required in Tables ?? and ??
83 (lib.locale.category). Their members use their ios_base&,
84 ios_base::iostate&, and fill arguments as described in
85 (lib.locale.categories), and the ctype<> facet, to determine
90 22.2 - Standard locale categories [lib.locale.categories]
92 -1- Each of the standard categories includes a family of facets. Some
93 of these implement formatting or parsing of a datum, for use by
94 standard or users' iostream operators << and >>, as members put() and
95 get(), respectively. Each such member function takes an ios_base&
96 argument whose members flags(), precision(), and width(), specify the
97 format of the corresponding datum. (lib.ios.base). Those functions
98 which need to use other facets call its member getloc() to retrieve
99 the locale imbued there. Formatting facets use the character argument
100 fill to fill out the specified width where necessary.
104 With GCC/libstdc++, the output of the program with the arguments
114 With Intel C++, it is: (this is clearly wrong)
123 And with RogueWave C++