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