19720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block/*
29720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Copyright (c) 1999
39720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Silicon Graphics Computer Systems, Inc.
49720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
59720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Copyright (c) 1999
69720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Boris Fomitchev
79720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
89720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * This material is provided "as is", with absolutely no warranty expressed
99720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * or implied. Any use is at your own risk.
109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Permission to use or copy this software for any purpose is hereby granted
129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * without fee, provided the above notices are retained on all copies.
139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * Permission to modify the code and to distribute modified code is granted,
149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * provided the above notices are retained, and a notice that the code was
159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block * modified is included with the above copyright notice.
169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block *
179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block */
189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_TIME_FACETS_C
199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#define _STLP_TIME_FACETS_C
209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_TIME_FACETS_H
229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_time_facets.h>
239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_NUM_PUT_H
269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_num_put.h>
279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#ifndef _STLP_INTERNAL_NUM_GET_H
309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#  include <stl/_num_get.h>
319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif
329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_BEGIN_NAMESPACE
349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//----------------------------------------------------------------------
369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Declarations of static template members.
379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _InputIterator>
399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocklocale::id time_get<_CharT, _InputIterator>::id;
409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _CharT, class _OutputIterator>
429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocklocale::id time_put<_CharT, _OutputIterator>::id;
439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
44e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott_STLP_MOVE_TO_PRIV_NAMESPACE
459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
46e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott/* Matching input against a list of names
47e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
48e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * Alphabetic input of the names of months and the names
49e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * of weekdays requires matching input against a list of names.
50e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * We use a simple generic algorithm to accomplish this.  This
51e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * algorithm is not very efficient, especially for longer lists
52e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * of names, but it probably does not matter for the initial
53e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * implementation and it may never matter, since we do not expect
54e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * this kind of input to be used very often.  The algorithm
55e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * could be improved fairly simply by creating a new list of
56e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * names still in the running at each iteration.  A more sophisticated
57e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * approach would be to build a tree to do the matching.
58e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott *
59e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * We compare each character of the input to the corresponding
60e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * character of each name on the list that has not been eliminated,
61e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * either because every character in the name has already been
62e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * matched, or because some character has not been matched.  We
63e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * continue only as long as there are some names that have not been
64e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * eliminated.
65e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
66e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * We do not really need a random access iterator (a forward iterator
67e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * would do), but the extra generality makes the notation clumsier,
68e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * and we don't really need it.
69e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
70e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * We can recognize a failed match by the fact that the return value
71e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott * will be __name_end.
72e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott */
739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
74e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#define _MAXNAMES        24
759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
76e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scotttemplate <class _InIt, class _NameIt>
77e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t _STLP_CALL
78e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott__match(_InIt& __first, _InIt& __last, _NameIt __name, _NameIt __name_end) {
799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef ptrdiff_t difference_type;
809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  difference_type __n = __name_end - __name;
81e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  difference_type __i, __start = 0;
829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  size_t __pos = 0;
839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  difference_type __check_count = __n;
84e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  bool __do_not_check[_MAXNAMES];
85e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_t __matching_name_index = __n;
869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
87e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  memset(__do_not_check, 0, sizeof(__do_not_check));
889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  while (__first != __last) {
90e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    difference_type __new_n = __n;
91e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    for (__i = __start; __i < __n; ++__i) {
92e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      if (!__do_not_check[__i]) {
93e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        if (*__first == __name[__i][__pos]) {
949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (__pos == (__name[__i].size() - 1)) {
95e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott            __matching_name_index = __i;
96e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott            __do_not_check[__i] = true;
97e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott            if (__i == __start) ++__start;
989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            --__check_count;
999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            if (__check_count == 0) {
1009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block              ++__first;
101e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott              return __matching_name_index;
1029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            }
1039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          }
104e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          __new_n = __i + 1;
1059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
1069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        else {
107e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          __do_not_check[__i] = true;
108e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__i == __start) ++__start;
1099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          --__check_count;
1109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (__check_count == 0)
111e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott            return __matching_name_index;
1129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
1139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
114e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      else {
115e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        if (__i == __start) ++ __start;
116e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott      }
1179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
1189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
119e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    __n = __new_n;
1209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    ++__first; ++__pos;
1219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
1229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
123e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  return __matching_name_index;
1249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
1259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// __get_formatted_time reads input that is assumed to be formatted
1279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// according to the rules for the C strftime function (C standard,
1289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// 7.12.3.5).  This function is used to implement the do_get_time
1299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// and do_get_date virtual functions, which depend on the locale
1309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// specifications for the time and day formats respectively.
1319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Note the catchall default case, intended mainly for the '%Z'
1329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// format designator, which does not make sense here since the
1339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// representation of timezones is not part of the locale.
1349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//
1359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// The case branches are implemented either by doing a match using
1369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// the appopriate name table or by doing a __get_integer_nogroup.
1379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//
1389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// 'y' format is assumed to mean that the input represents years
1399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// since 1900.  That is, 2002 should be represented as 102.  There
1409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// is no century-guessing.
1419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block//
1429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// The match is successful if and only if the second component of the
1439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// return value is format_end.
1449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Note that the antepenultimate parameter is being used only to determine
1469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// the correct overloading for the calls to __get_integer_nogroup.
147e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scotttemplate <class _InIt1, class _Ch, class _TimeInfo>
1489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockstring::const_iterator _STLP_CALL
1499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block__get_formatted_time _STLP_WEAK (_InIt1 __first,  _InIt1 __last,
1509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                 string::const_iterator __format, string::const_iterator __format_end,
151e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                 _Ch*, const _TimeInfo& __table,
1529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                 const ios_base& __s, ios_base::iostate& __err, tm* __t) {
153e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  const ctype<_Ch>& __ct = use_facet<ctype<_Ch> >(__s.getloc());
154e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  typedef basic_string<_Ch, char_traits<_Ch>, allocator<_Ch> > string_type;
155e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_t offset;
156e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott
1579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  while (__first != __last && __format != __format_end) {
158e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    offset = 0;
1599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (*__format == '%') {
1609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      ++__format;
1619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      char __c = *__format;
1629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      if (__c == '#') { //MS extension
1639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        ++__format;
1649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        __c = *__format;
1659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
1669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      switch (__c) {
168e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        case 'A':
169e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          offset = 7;
1709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'a': {
171e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          size_t __index = __match(__first, __last,
172e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                   __table._M_dayname + offset, __table._M_dayname + offset + 7);
173e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__index == 7)
1749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
175e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          __t->tm_wday = __STATIC_CAST(int, __index);
1769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
1779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
1789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
179e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott        case 'B':
180e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          offset = 12;
1819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'b': {
182e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          size_t __index = __match(__first, __last,
183e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                   __table._M_monthname + offset, __table._M_monthname + offset + 12);
184e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__index == 12)
1859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
186e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          __t->tm_mon = __STATIC_CAST(int, __index);
1879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
1889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
1899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'd': {
1919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_mday, __STATIC_CAST(_Ch*, 0));
1929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr || __t->tm_mday < 1 || __t->tm_mday > 31) {
1939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            __err |= ios_base::failbit;
1949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
1959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          }
1969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
1979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
1989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
1999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'H': case 'I': {
2009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_hour, __STATIC_CAST(_Ch*, 0));
2019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'j': {
2079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_yday, __STATIC_CAST(_Ch*, 0));
2089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'm': {
2149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_mon, __STATIC_CAST(_Ch*, 0));
2159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          --__t->tm_mon;
2169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr || __t->tm_mon < 0 || __t->tm_mon > 11) {
2179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            __err |= ios_base::failbit;
2189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          }
2209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'M': {
2249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_min, __STATIC_CAST(_Ch*, 0));
2259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'p': {
231e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          size_t __index = __match(__first, __last,
232e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                   __table._M_am_pm + 0, __table._M_am_pm + 2);
233e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__index == 2)
2349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          // 12:00 PM <=> 12:00, 12:00 AM <=> 00:00
236e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__index == 1 && __t->tm_hour != 12 )
2379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            __t->tm_hour += 12;
238e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott          if (__index == 0 && __t->tm_hour == 12 )
2399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            __t->tm_hour = 0;
2409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'S': {
2449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_sec, __STATIC_CAST(_Ch*, 0));
2459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'y': {
2519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0));
2529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        case 'Y': {
2589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          bool __pr = __get_decimal_integer(__first, __last, __t->tm_year, __STATIC_CAST(_Ch*, 0));
2599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          __t->tm_year -= 1900;
2609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          if (!__pr)
2619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block            return __format;
2629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        }
2649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        default:
2669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block          break;
2679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
2689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
2699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else {
2709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      if (*__first++ != __ct.widen(*__format)) break;
2719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
2729720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    ++__format;
2749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
2759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
2769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __format;
2779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
2789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
279e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scotttemplate <class _InIt, class _TimeInfo>
2809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockbool _STLP_CALL
281e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott__get_short_or_long_dayname(_InIt& __first, _InIt& __last, const _TimeInfo& __table, tm* __t) {
282e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_t __index = __match(__first, __last, __table._M_dayname + 0, __table._M_dayname + 14);
283e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  if (__index != 14) {
284e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    __t->tm_wday = __STATIC_CAST(int, __index % 7);
285e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    return true;
286e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  }
287e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  return false;
2889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
2899720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
290e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scotttemplate <class _InIt, class _TimeInfo>
2919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blockbool _STLP_CALL
292e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott__get_short_or_long_monthname(_InIt& __first, _InIt& __last, const _TimeInfo& __table, tm* __t) {
293e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  size_t __index = __match(__first, __last, __table._M_monthname + 0, __table._M_monthname + 24);
294e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  if (__index != 24) {
295e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    __t->tm_mon = __STATIC_CAST(int, __index % 12);
296e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    return true;
297e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  }
298e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  return false;
2999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_MOVE_TO_STD_NAMESPACE
3029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _Ch, class _InIt>
3049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_InIt
3059720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_get<_Ch, _InIt>::do_get_date(_InIt __s, _InIt  __end,
3069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  ios_base& __str, ios_base::iostate&  __err,
3079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  tm* __t) const {
3089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef string::const_iterator string_iterator;
3099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
310e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  string_iterator __format = this->_M_timeinfo._M_date_format.begin();
311e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  string_iterator __format_end = this->_M_timeinfo._M_date_format.end();
3129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  string_iterator __result
3149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end,
315e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                      __STATIC_CAST(_Ch*, 0), this->_M_timeinfo,
3169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                      __str, __err, __t);
3179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__result == __format_end)
3189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::goodbit;
3199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  else {
3209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::failbit;
3219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__s == __end)
3229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __err |= ios_base::eofbit;
3239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
3259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _Ch, class _InIt>
3289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_InIt
3299720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_get<_Ch, _InIt>::do_get_time(_InIt __s, _InIt  __end,
3309720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  ios_base& __str, ios_base::iostate&  __err,
3319720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  tm* __t) const {
3329720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  typedef string::const_iterator string_iterator;
333e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  string_iterator __format = this->_M_timeinfo._M_time_format.begin();
334e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  string_iterator __format_end = this->_M_timeinfo._M_time_format.end();
3359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  string_iterator __result
3379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    = _STLP_PRIV __get_formatted_time(__s, __end, __format, __format_end,
338e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott                                      __STATIC_CAST(_Ch*, 0), this->_M_timeinfo,
3399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                      __str, __err, __t);
3409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  __err = __result == __format_end ? ios_base::goodbit
3419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                   : ios_base::failbit;
3429720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__s == __end)
3439720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err |= ios_base::eofbit;
3449720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
3459720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3469720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3479720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _Ch, class _InIt>
3489720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_InIt
3499720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_get<_Ch, _InIt>::do_get_year(_InIt __s, _InIt  __end,
3509720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  ios_base&, ios_base::iostate&  __err,
3519720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  tm* __t) const {
3529720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__s == __end) {
3539720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::failbit | ios_base::eofbit;
3549720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    return __s;
3559720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3569720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3579720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  bool __pr =  _STLP_PRIV __get_decimal_integer(__s, __end, __t->tm_year, __STATIC_CAST(_Ch*, 0));
3589720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  __t->tm_year -= 1900;
3599720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  __err = __pr ? ios_base::goodbit : ios_base::failbit;
3609720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__s == __end)
3619720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err |= ios_base::eofbit;
3629720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3639720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
3649720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3659720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3669720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _Ch, class _InIt>
3679720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_InIt
3689720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_get<_Ch, _InIt>::do_get_weekday(_InIt __s, _InIt  __end,
3699720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                     ios_base &__str, ios_base::iostate &__err,
3709720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                     tm *__t) const {
3719720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  bool __result =
372e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    _STLP_PRIV __get_short_or_long_dayname(__s, __end, this->_M_timeinfo, __t);
3739720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__result)
3749720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::goodbit;
3759720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  else {
3769720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::failbit;
3779720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__s == __end)
3789720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __err |= ios_base::eofbit;
3799720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3809720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
3819720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3829720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
3839720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate <class _Ch, class _InIt>
3849720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_InIt
3859720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_get<_Ch, _InIt>::do_get_monthname(_InIt __s, _InIt  __end,
3869720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                       ios_base &__str, ios_base::iostate &__err,
3879720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                       tm *__t) const {
3889720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  bool __result =
389e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott    _STLP_PRIV __get_short_or_long_monthname(__s, __end, this->_M_timeinfo, __t);
3909720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  if (__result)
3919720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::goodbit;
3929720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  else {
3939720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    __err = ios_base::failbit;
3949720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__s == __end)
3959720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __err |= ios_base::eofbit;
3969720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
3979720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
3989720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
3999720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4009720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate<class _Ch, class _OutputIter>
4019720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_OutputIter
4029720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_put<_Ch,_OutputIter>::put(_OutputIter __s, ios_base& __f, _Ch __fill,
4039720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                               const tm* __tmb, const _Ch* __pat,
4049720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                               const _Ch* __pat_end) const {
405e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  const ctype<_Ch>& _Ct = use_facet<ctype<_Ch> >(__f.getloc());
4069720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  while (__pat != __pat_end) {
4079720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    char __c = _Ct.narrow(*__pat, 0);
4089720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    if (__c == '%') {
4099720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      char __mod = 0;
4109720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      ++__pat;
4119720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __c = _Ct.narrow(*__pat++, 0);
4129720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      if (__c == '#') { // MS extension
4139720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        __mod = __c;
4149720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block        __c = _Ct.narrow(*__pat++, 0);
4159720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      }
4169720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      __s = do_put(__s, __f, __fill, __tmb, __c, __mod);
4179720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    }
4189720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block    else
4199720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block      *__s++ = *__pat++;
4209720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  }
4219720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block  return __s;
4229720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
4239720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4249720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktemplate<class _Ch, class _OutputIter>
4259720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_OutputIter
4269720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Blocktime_put<_Ch,_OutputIter>::do_put(_OutputIter __s, ios_base& __f, _Ch /* __fill */,
4279720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  const tm* __tmb, char __format,
4289720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block                                  char __modifier ) const {
429e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  const ctype<_Ch>& __ct = use_facet<ctype<_Ch> >(__f.getloc());
430e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  _STLP_BASIC_IOSTRING(_Ch) __buf;
431e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  _STLP_PRIV __write_formatted_time(__buf, __ct, __format, __modifier, this->_M_timeinfo, __tmb);
432e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott  return copy(__buf.begin(), __buf.end(), __s);
4339720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block}
4349720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4359720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block_STLP_END_NAMESPACE
4369720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4379720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block#endif /* _STLP_TIME_FACETS_C */
4389720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block
4399720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// Local Variables:
4409720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// mode:C++
4419720d5f59b9c1f5d1b9ecbc9173dbcb71bd557beSteve Block// End:
442