Changeset 17031 in webkit for trunk/JavaScriptCore/kjs/DateMath.h
- Timestamp:
- Oct 13, 2006, 10:31:11 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/DateMath.h
r17010 r17031 48 48 // Intentionally overridding the default tm of the system 49 49 // Not all OS' have the same members of their tm's 50 struct tm { 51 int tm_sec; 52 int tm_min; 53 int tm_hour; 54 int tm_wday; 55 int tm_mday; 56 int tm_yday; 57 int tm_mon; 58 int tm_year; 59 int tm_isdst; 60 long tm_gmtoff; 61 char* tm_zone; 50 struct GregorianDateTime { 51 GregorianDateTime() 52 { 53 second = 0; 54 minute = 0; 55 hour = 0; 56 weekDay = 0; 57 monthDay = 0; 58 yearDay = 0; 59 month = 0; 60 year = 0; 61 isDST = 0; 62 utcOffset = 0; 63 timeZone = NULL; 64 } 65 66 ~GregorianDateTime() 67 { 68 if (timeZone) 69 delete timeZone; 70 } 71 72 GregorianDateTime(const tm& inTm) 73 : second(inTm.tm_sec) 74 , minute(inTm.tm_min) 75 , hour(inTm.tm_hour) 76 , weekDay(inTm.tm_wday) 77 , monthDay(inTm.tm_mday) 78 , yearDay(inTm.tm_yday) 79 , month(inTm.tm_mon) 80 , year(inTm.tm_year) 81 , isDST(inTm.tm_isdst) 82 { 83 #if !PLATFORM(WIN_OS) 84 utcOffset = static_cast<int>(inTm.tm_gmtoff); 85 86 int inZoneSize = strlen(inTm.tm_zone) + 1; 87 timeZone = new char[inZoneSize]; 88 strncpy(timeZone, inTm.tm_zone, inZoneSize); 89 #else 90 utcOffset = 0; 91 timeZone = NULL; 92 #endif 93 } 94 95 tm toTM() const 96 { 97 tm ret; 98 memset(&ret, 0, sizeof(ret)); 99 100 ret.tm_sec = second; 101 ret.tm_min = minute; 102 ret.tm_hour = hour; 103 ret.tm_wday = weekDay; 104 ret.tm_mday = monthDay; 105 ret.tm_yday = yearDay; 106 ret.tm_mon = month; 107 ret.tm_year = year; 108 ret.tm_isdst = isDST; 109 110 #if !PLATFORM(WIN_OS) 111 ret.tm_gmtoff = static_cast<long>(utcOffset); 112 ret.tm_zone = timeZone; 113 #endif 114 115 return ret; 116 } 117 118 int second; 119 int minute; 120 int hour; 121 int weekDay; 122 int monthDay; 123 int yearDay; 124 int month; 125 int year; 126 int isDST; 127 int utcOffset; 128 char* timeZone; 62 129 }; 63 130 … … 76 143 77 144 // Exported Functions // 78 void msTo TM(double, bool outputIsUTC, struct tm&);79 double dateToMS(const tm&, double, bool inputIsUTC);145 void msToGregorianDateTime(double, bool outputIsUTC, struct GregorianDateTime&); 146 double gregorianDateTimeToMS(const GregorianDateTime&, double, bool inputIsUTC); 80 147 double getUTCOffset(); 81 82 tm tmToKJStm(const struct ::tm&);83 ::tm KJStmToTm(const struct tm&);84 148 85 149 } //namespace KJS
Note:
See TracChangeset
for help on using the changeset viewer.