1 // std::time_get, std::time_put implementation, generic version -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
32 // ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
35 // Written by Benjamin Kosnik <bkoz@redhat.com>
44 _M_put(char* __s
, size_t __maxlen
, const char* __format
,
47 char* __old
= strdup(setlocale(LC_ALL
, NULL
));
48 setlocale(LC_ALL
, _M_name_timepunct
);
49 strftime(__s
, __maxlen
, __format
, __tm
);
50 setlocale(LC_ALL
, __old
);
56 __timepunct
<char>::_M_initialize_timepunct(__c_locale
)
60 _M_data
= new __timepunct_cache
<char>;
62 _M_data
->_M_date_format
= "%m/%d/%y";
63 _M_data
->_M_date_era_format
= "%m/%d/%y";
64 _M_data
->_M_time_format
= "%H:%M:%S";
65 _M_data
->_M_time_era_format
= "%H:%M:%S";
66 _M_data
->_M_date_time_format
= "";
67 _M_data
->_M_date_time_era_format
= "";
68 _M_data
->_M_am
= "AM";
69 _M_data
->_M_pm
= "PM";
70 _M_data
->_M_am_pm_format
= "";
72 // Day names, starting with "C"'s Sunday.
73 _M_data
->_M_day1
= "Sunday";
74 _M_data
->_M_day2
= "Monday";
75 _M_data
->_M_day3
= "Tuesday";
76 _M_data
->_M_day4
= "Wednesday";
77 _M_data
->_M_day5
= "Thursday";
78 _M_data
->_M_day6
= "Friday";
79 _M_data
->_M_day7
= "Saturday";
81 // Abbreviated day names, starting with "C"'s Sun.
82 _M_data
->_M_aday1
= "Sun";
83 _M_data
->_M_aday2
= "Mon";
84 _M_data
->_M_aday3
= "Tue";
85 _M_data
->_M_aday4
= "Wed";
86 _M_data
->_M_aday5
= "Thu";
87 _M_data
->_M_aday6
= "Fri";
88 _M_data
->_M_aday7
= "Sat";
90 // Month names, starting with "C"'s January.
91 _M_data
->_M_month01
= "January";
92 _M_data
->_M_month02
= "February";
93 _M_data
->_M_month03
= "March";
94 _M_data
->_M_month04
= "April";
95 _M_data
->_M_month05
= "May";
96 _M_data
->_M_month06
= "June";
97 _M_data
->_M_month07
= "July";
98 _M_data
->_M_month08
= "August";
99 _M_data
->_M_month09
= "September";
100 _M_data
->_M_month10
= "October";
101 _M_data
->_M_month11
= "November";
102 _M_data
->_M_month12
= "December";
104 // Abbreviated month names, starting with "C"'s Jan.
105 _M_data
->_M_amonth01
= "Jan";
106 _M_data
->_M_amonth02
= "Feb";
107 _M_data
->_M_amonth03
= "Mar";
108 _M_data
->_M_amonth04
= "Apr";
109 _M_data
->_M_amonth05
= "May";
110 _M_data
->_M_amonth06
= "Jun";
111 _M_data
->_M_amonth07
= "July";
112 _M_data
->_M_amonth08
= "Aug";
113 _M_data
->_M_amonth09
= "Sep";
114 _M_data
->_M_amonth10
= "Oct";
115 _M_data
->_M_amonth11
= "Nov";
116 _M_data
->_M_amonth12
= "Dec";
119 #ifdef _GLIBCXX_USE_WCHAR_T
122 __timepunct
<wchar_t>::
123 _M_put(wchar_t* __s
, size_t __maxlen
, const wchar_t* __format
,
124 const tm
* __tm
) const
126 char* __old
= strdup(setlocale(LC_ALL
, NULL
));
127 setlocale(LC_ALL
, _M_name_timepunct
);
128 wcsftime(__s
, __maxlen
, __format
, __tm
);
129 setlocale(LC_ALL
, __old
);
135 __timepunct
<wchar_t>::_M_initialize_timepunct(__c_locale
)
139 _M_data
= new __timepunct_cache
<wchar_t>;
141 _M_data
->_M_date_format
= L
"%m/%d/%y";
142 _M_data
->_M_date_era_format
= L
"%m/%d/%y";
143 _M_data
->_M_time_format
= L
"%H:%M:%S";
144 _M_data
->_M_time_era_format
= L
"%H:%M:%S";
145 _M_data
->_M_date_time_format
= L
"";
146 _M_data
->_M_date_time_era_format
= L
"";
147 _M_data
->_M_am
= L
"AM";
148 _M_data
->_M_pm
= L
"PM";
149 _M_data
->_M_am_pm_format
= L
"";
151 // Day names, starting with "C"'s Sunday.
152 _M_data
->_M_day1
= L
"Sunday";
153 _M_data
->_M_day2
= L
"Monday";
154 _M_data
->_M_day3
= L
"Tuesday";
155 _M_data
->_M_day4
= L
"Wednesday";
156 _M_data
->_M_day5
= L
"Thursday";
157 _M_data
->_M_day6
= L
"Friday";
158 _M_data
->_M_day7
= L
"Saturday";
160 // Abbreviated day names, starting with "C"'s Sun.
161 _M_data
->_M_aday1
= L
"Sun";
162 _M_data
->_M_aday2
= L
"Mon";
163 _M_data
->_M_aday3
= L
"Tue";
164 _M_data
->_M_aday4
= L
"Wed";
165 _M_data
->_M_aday5
= L
"Thu";
166 _M_data
->_M_aday6
= L
"Fri";
167 _M_data
->_M_aday7
= L
"Sat";
169 // Month names, starting with "C"'s January.
170 _M_data
->_M_month01
= L
"January";
171 _M_data
->_M_month02
= L
"February";
172 _M_data
->_M_month03
= L
"March";
173 _M_data
->_M_month04
= L
"April";
174 _M_data
->_M_month05
= L
"May";
175 _M_data
->_M_month06
= L
"June";
176 _M_data
->_M_month07
= L
"July";
177 _M_data
->_M_month08
= L
"August";
178 _M_data
->_M_month09
= L
"September";
179 _M_data
->_M_month10
= L
"October";
180 _M_data
->_M_month11
= L
"November";
181 _M_data
->_M_month12
= L
"December";
183 // Abbreviated month names, starting with "C"'s Jan.
184 _M_data
->_M_amonth01
= L
"Jan";
185 _M_data
->_M_amonth02
= L
"Feb";
186 _M_data
->_M_amonth03
= L
"Mar";
187 _M_data
->_M_amonth04
= L
"Apr";
188 _M_data
->_M_amonth05
= L
"May";
189 _M_data
->_M_amonth06
= L
"Jun";
190 _M_data
->_M_amonth07
= L
"July";
191 _M_data
->_M_amonth08
= L
"Aug";
192 _M_data
->_M_amonth09
= L
"Sep";
193 _M_data
->_M_amonth10
= L
"Oct";
194 _M_data
->_M_amonth11
= L
"Nov";
195 _M_data
->_M_amonth12
= L
"Dec";