comparison src/strftime.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents bbff43aa5eb7
children de805c49cfc1
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
110 enum padding 110 enum padding
111 { 111 {
112 none, blank, zero 112 none, blank, zero
113 }; 113 };
114 114
115 static char CONST* CONST days[] = 115 static char const* const days[] =
116 { 116 {
117 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" 117 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
118 }; 118 };
119 119
120 static char CONST * CONST months[] = 120 static char const * const months[] =
121 { 121 {
122 "January", "February", "March", "April", "May", "June", 122 "January", "February", "March", "April", "May", "June",
123 "July", "August", "September", "October", "November", "December" 123 "July", "August", "September", "October", "November", "December"
124 }; 124 };
125 125
172 } 172 }
173 173
174 /* Like strncpy except return the number of characters copied. */ 174 /* Like strncpy except return the number of characters copied. */
175 175
176 static int 176 static int
177 add_str (char *to, CONST char *from, int max) 177 add_str (char *to, const char *from, int max)
178 { 178 {
179 int i; 179 int i;
180 180
181 for (i = 0; from[i] && i <= max; ++i) 181 for (i = 0; from[i] && i <= max; ++i)
182 to[i] = from[i]; 182 to[i] = from[i];
201 201
202 /* Return the week in the year of the time in TM, with the weeks 202 /* Return the week in the year of the time in TM, with the weeks
203 starting on Sundays. */ 203 starting on Sundays. */
204 204
205 static int 205 static int
206 sun_week (CONST struct tm *tm) 206 sun_week (const struct tm *tm)
207 { 207 {
208 int dl; 208 int dl;
209 209
210 /* Set `dl' to the day in the year of the last day of the week previous 210 /* Set `dl' to the day in the year of the last day of the week previous
211 to the one containing the day specified in TM. If the day specified 211 to the one containing the day specified in TM. If the day specified
218 218
219 /* Return the week in the year of the time in TM, with the weeks 219 /* Return the week in the year of the time in TM, with the weeks
220 starting on Mondays. */ 220 starting on Mondays. */
221 221
222 static int 222 static int
223 mon_week (CONST struct tm *tm) 223 mon_week (const struct tm *tm)
224 { 224 {
225 int dl, wday; 225 int dl, wday;
226 226
227 if (tm->tm_wday == 0) 227 if (tm->tm_wday == 0)
228 wday = 6; 228 wday = 6;
232 return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0); 232 return dl <= 0 ? 0 : dl / 7 + (dl % 7 != 0);
233 } 233 }
234 234
235 #if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME) 235 #if !defined(HAVE_TM_ZONE) && !defined(HAVE_TZNAME)
236 char * 236 char *
237 zone_name (CONST struct tm *tp) 237 zone_name (const struct tm *tp)
238 { 238 {
239 char *timezone (); 239 char *timezone ();
240 struct timeval tv; 240 struct timeval tv;
241 struct timezone tz; 241 struct timezone tz;
242 242
249 results in STRING. 249 results in STRING.
250 Return the number of characters (not including terminating null) 250 Return the number of characters (not including terminating null)
251 that were put into STRING, or 0 if the length would have 251 that were put into STRING, or 0 if the length would have
252 exceeded MAX. */ 252 exceeded MAX. */
253 253
254 size_t strftime (char *string, size_t max, CONST char *format, 254 size_t strftime (char *string, size_t max, const char *format,
255 CONST struct tm *tm); 255 const struct tm *tm);
256 256
257 size_t 257 size_t
258 strftime (char *string, size_t max, CONST char *format, CONST struct tm *tm) 258 strftime (char *string, size_t max, const char *format, const struct tm *tm)
259 { 259 {
260 enum padding pad; /* Type of padding to apply. */ 260 enum padding pad; /* Type of padding to apply. */
261 size_t length = 0; /* Characters put in STRING so far. */ 261 size_t length = 0; /* Characters put in STRING so far. */
262 262
263 for (; *format && length < max; ++format) 263 for (; *format && length < max; ++format)