Changeset 41909 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Mar 23, 2009, 8:13:57 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r41823 r41909 28 28 #include "DateInstance.h" 29 29 #include <float.h> 30 31 #if !PLATFORM(MAC) && HAVE(LANGINFO_H) 32 #include <langinfo.h> 33 #endif 34 30 35 #include <limits.h> 31 36 #include <locale.h> … … 182 187 static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format) 183 188 { 189 #if HAVE(LANGINFO_H) 190 static const nl_item formats[] = { D_T_FMT, D_FMT, T_FMT }; 191 #else 184 192 static const char* const formatStrings[] = { "%#c", "%#x", "%X" }; 193 #endif 185 194 186 195 // Offset year if needed … … 191 200 localTM.tm_year = equivalentYearForDST(year) - 1900; 192 201 202 #if HAVE(LANGINFO_H) 203 // We do not allow strftime to generate dates with 2-digits years, 204 // both to avoid ambiguity, and a crash in strncpy, for years that 205 // need offset. 206 char* formatString = strdup(nl_langinfo(formats[format])); 207 char* yPos = strchr(formatString, 'y'); 208 if (yPos) 209 *yPos = 'Y'; 210 #endif 211 193 212 // Do the formatting 194 213 const int bufsize = 128; 195 214 char timebuffer[bufsize]; 215 216 #if HAVE(LANGINFO_H) 217 size_t ret = strftime(timebuffer, bufsize, formatString, &localTM); 218 free(formatString); 219 #else 196 220 size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM); 221 #endif 197 222 198 223 if (ret == 0)
Note:
See TracChangeset
for help on using the changeset viewer.