Changeset 41818 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Mar 18, 2009, 4:21:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/DatePrototype.cpp
r40046 r41818 28 28 #include "DateInstance.h" 29 29 #include <float.h> 30 #include <langinfo.h> 30 31 #include <limits.h> 31 32 #include <locale.h> … … 182 183 static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format) 183 184 { 184 static const char* const formatStrings[] = { "%#c", "%#x", "%X"};185 static const nl_item formats[] = { D_T_FMT, D_FMT, T_FMT }; 185 186 186 187 // Offset year if needed … … 191 192 localTM.tm_year = equivalentYearForDST(year) - 1900; 192 193 194 // We do not allow strftime to generate dates with 2-digits years, 195 // both to avoid ambiguity, and a crash in strncpy, for years that 196 // need offset. 197 char* formatString = strdup(nl_langinfo(formats[format])); 198 char* yPos = strchr(formatString, 'y'); 199 if (yPos) 200 *yPos = 'Y'; 201 193 202 // Do the formatting 194 203 const int bufsize = 128; 195 204 char timebuffer[bufsize]; 196 size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM); 205 size_t ret = strftime(timebuffer, bufsize, formatString, &localTM); 206 207 free(formatString); 197 208 198 209 if (ret == 0)
Note:
See TracChangeset
for help on using the changeset viewer.