Changeset 19945 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Mar 2, 2007, 11:55:21 AM (18 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/DateMath.cpp
r19943 r19945 402 402 } 403 403 404 void msToGregorianDateTime(double ms, bool outputIsUTC, structGregorianDateTime& tm)404 void msToGregorianDateTime(double ms, bool outputIsUTC, GregorianDateTime& tm) 405 405 { 406 406 // input is UTC -
trunk/JavaScriptCore/kjs/DateMath.h
r19943 r19945 48 48 namespace KJS { 49 49 50 struct GregorianDateTime; 51 52 void msToGregorianDateTime(double, bool outputIsUTC, GregorianDateTime&); 53 double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC); 54 double getUTCOffset(); 55 int equivalentYearForDST(int year); 56 50 57 const char * const weekdayName[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; 51 58 const char * const monthName[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; … … 62 69 // Intentionally overridding the default tm of the system 63 70 // Not all OS' have the same members of their tm's 64 struct GregorianDateTime : Noncopyable {71 struct GregorianDateTime : Noncopyable { 65 72 GregorianDateTime() 66 73 : second(0) … … 142 149 }; 143 150 144 void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&);145 double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC);146 double getUTCOffset();147 int equivalentYearForDST(int year);148 149 151 } //namespace KJS 150 152 -
trunk/JavaScriptCore/kjs/date_object.cpp
r18658 r19945 159 159 enum LocaleDateTimeFormat { LocaleDateAndTime, LocaleDate, LocaleTime }; 160 160 161 static JSCell* formatLocaleDate( GregorianDateTimegdt, const LocaleDateTimeFormat format)161 static JSCell* formatLocaleDate(const GregorianDateTime& gdt, const LocaleDateTimeFormat format) 162 162 { 163 163 static const char* formatStrings[] = {"%#c", "%#x", "%X"}; … … 165 165 // Offset year if needed 166 166 struct tm localTM = gdt; 167 gdt.year +=1900;168 bool yearNeedsOffset = gdt.year < 1900 || gdt.year > 2038;167 int year = gdt.year + 1900; 168 bool yearNeedsOffset = year < 1900 || year > 2038; 169 169 if (yearNeedsOffset) { 170 localTM.tm_year = equivalentYearForDST( gdt.year) - 1900;170 localTM.tm_year = equivalentYearForDST(year) - 1900; 171 171 } 172 172 … … 186 186 snprintf(yearString, yearLen, "%d", localTM.tm_year + 1900); 187 187 char* yearLocation = strstr(timebuffer, yearString); 188 snprintf(yearString, yearLen, "%d", gdt.year);188 snprintf(yearString, yearLen, "%d", year); 189 189 190 190 strncpy(yearLocation, yearString, yearLen - 1);
Note:
See TracChangeset
for help on using the changeset viewer.