| 1 | /* |
| 2 | * Copyright (C) 1999-2000 Harri Porten ([email protected]) |
| 3 | * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2009 Google Inc. All rights reserved. |
| 5 | * |
| 6 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 7 | * |
| 8 | * The contents of this file are subject to the Mozilla Public License Version |
| 9 | * 1.1 (the "License"); you may not use this file except in compliance with |
| 10 | * the License. You may obtain a copy of the License at |
| 11 | * http://www.mozilla.org/MPL/ |
| 12 | * |
| 13 | * Software distributed under the License is distributed on an "AS IS" basis, |
| 14 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 15 | * for the specific language governing rights and limitations under the |
| 16 | * License. |
| 17 | * |
| 18 | * The Original Code is Mozilla Communicator client code, released |
| 19 | * March 31, 1998. |
| 20 | * |
| 21 | * The Initial Developer of the Original Code is |
| 22 | * Netscape Communications Corporation. |
| 23 | * Portions created by the Initial Developer are Copyright (C) 1998 |
| 24 | * the Initial Developer. All Rights Reserved. |
| 25 | * |
| 26 | * Contributor(s): |
| 27 | * |
| 28 | * Alternatively, the contents of this file may be used under the terms of |
| 29 | * either of the GNU General Public License Version 2 or later (the "GPL"), |
| 30 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 31 | * in which case the provisions of the GPL or the LGPL are applicable instead |
| 32 | * of those above. If you wish to allow use of your version of this file only |
| 33 | * under the terms of either the GPL or the LGPL, and not to allow others to |
| 34 | * use your version of this file under the terms of the MPL, indicate your |
| 35 | * decision by deleting the provisions above and replace them with the notice |
| 36 | * and other provisions required by the GPL or the LGPL. If you do not delete |
| 37 | * the provisions above, a recipient may use your version of this file under |
| 38 | * the terms of any one of the MPL, the GPL or the LGPL. |
| 39 | * |
| 40 | */ |
| 41 | |
| 42 | #ifndef DateMath_h |
| 43 | #define DateMath_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.h:43:9`! |
| 44 | |
| 45 | #include <math.h> |
| 46 | #include <string.h> |
| 47 | #include <time.h> |
| 48 | #include <wtf/CurrentTime.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/CurrentTime.h`/ |
| 49 | #include <wtf/Noncopyable.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Noncopyable.h`/ |
| 50 | #include <wtf/UnusedParam.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/UnusedParam.h`/ |
| 51 | |
| 52 | namespace WTFcxx . . $ `<built-in>:467:9`! { |
| 53 | |
| 54 | struct LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset# { |
| 55 | LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset#LocalTimeOffset(49f6e7a06ebc5aa8).() |
| 56 | : isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST.(false) |
| 57 | , offsetcxx . . $ QTWTF/LocalTimeOffset#offset.(0) |
| 58 | { |
| 59 | } |
| 60 | |
| 61 | LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset#LocalTimeOffset(b994e01f1c45a386).(bool isDST, int offset) |
| 62 | : isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST.(isDST) |
| 63 | , offsetcxx . . $ QTWTF/LocalTimeOffset#offset.(offset) |
| 64 | { |
| 65 | } |
| 66 | |
| 67 | bool operatorcxx . . $ QTWTF/LocalTimeOffset#`operator==`(ee6c6240dee66e24).==(const LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset#& other) |
| 68 | { |
| 69 | return isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST. == other.isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST. && offsetcxx . . $ QTWTF/LocalTimeOffset#offset. == other.offsetcxx . . $ QTWTF/LocalTimeOffset#offset.; |
| 70 | } |
| 71 | |
| 72 | bool operatorcxx . . $ QTWTF/LocalTimeOffset#`operator!=`(ee6c6240dee66e24).!=(const LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset#& other) |
| 73 | { |
| 74 | return isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST. != other.isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST. || offsetcxx . . $ QTWTF/LocalTimeOffset#offset. != other.offsetcxx . . $ QTWTF/LocalTimeOffset#offset.; |
| 75 | } |
| 76 | |
| 77 | bool isDSTcxx . . $ QTWTF/LocalTimeOffset#isDST.; |
| 78 | int offsetcxx . . $ QTWTF/LocalTimeOffset#offset.; |
| 79 | }; |
| 80 | |
| 81 | void initializeDatescxx . . $ QTWTF/initializeDates(49f6e7a06ebc5aa8).(); |
| 82 | int equivalentYearForDSTcxx . . $ QTWTF/equivalentYearForDST(7864480464b09eea).(int year); |
| 83 | |
| 84 | // Not really math related, but this is currently the only shared place to put these. |
| 85 | double parseDateFromNullTerminatedCharacterscxx . . $ QTWTF/parseDateFromNullTerminatedCharacters(9a18bdb0e56c1bc2).(const char* dateString); |
| 86 | double timeClipcxx . . $ QTWTF/timeClip(447c67c6676f75c3).(double); |
| 87 | |
| 88 | inline double jsCurrentTimecxx . . $ QTWTF/jsCurrentTime(31fa7155c10fdd13).() |
| 89 | { |
| 90 | // JavaScript doesn't recognize fractions of a millisecond. |
| 91 | return floorcxx . . $ floor(447c67c6676f75c3).(WTFcxx . . $ `<built-in>:467:9`!::currentTimeMScxx . . $ QTWTF/currentTimeMS(31fa7155c10fdd13).()); |
| 92 | } |
| 93 | |
| 94 | const char * const weekdayNamecxx . . $ QTWTF/weekdayName.[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; |
| 95 | const char * const monthNamecxx . . $ QTWTF/monthName.[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; |
| 96 | |
| 97 | const double hoursPerDaycxx . . $ QTWTF/hoursPerDay. = 24.0; |
| 98 | const double minutesPerHourcxx . . $ QTWTF/minutesPerHour. = 60.0; |
| 99 | const double secondsPerHourcxx . . $ QTWTF/secondsPerHour. = 60.0 * 60.0; |
| 100 | const double secondsPerMinutecxx . . $ QTWTF/secondsPerMinute. = 60.0; |
| 101 | const double msPerSecondcxx . . $ QTWTF/msPerSecond. = 1000.0; |
| 102 | const double msPerMinutecxx . . $ QTWTF/msPerMinute. = 60.0 * 1000.0; |
| 103 | const double msPerHourcxx . . $ QTWTF/msPerHour. = 60.0 * 60.0 * 1000.0; |
| 104 | const double msPerDaycxx . . $ QTWTF/msPerDay. = 24.0 * 60.0 * 60.0 * 1000.0; |
| 105 | const double msPerMonthcxx . . $ QTWTF/msPerMonth. = 2592000000.0; |
| 106 | |
| 107 | // Returns the number of days from 1970-01-01 to the specified date. |
| 108 | double dateToDaysFrom1970cxx . . $ QTWTF/dateToDaysFrom1970(ec38aeb9d8f90526).(int year, int month, int day); |
| 109 | int msToYearcxx . . $ QTWTF/msToYear(620b9ac44d2573a6).(double ms); |
| 110 | int dayInYearcxx . . $ QTWTF/dayInYear(73c075bbbf02e8eb).(double ms, int year); |
| 111 | int monthFromDayInYearcxx . . $ QTWTF/monthFromDayInYear(d455ce14f374a3ab).(int dayInYear, bool leapYear); |
| 112 | int dayInMonthFromDayInYearcxx . . $ QTWTF/dayInMonthFromDayInYear(d455ce14f374a3ab).(int dayInYear, bool leapYear); |
| 113 | |
| 114 | // Returns combined offset in millisecond (UTC + DST). |
| 115 | LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset# calculateLocalTimeOffsetcxx . . $ QTWTF/calculateLocalTimeOffset(1c25f9c1a4fcccfc).(double utcInMilliseconds); |
| 116 | |
| 117 | } // namespace WTF |
| 118 | |
| 119 | using WTFcxx . . $ QTWTF/::dateToDaysFrom1970cxx . . $ dateToDaysFrom1970(ec38aeb9d8f90526).; |
| 120 | using WTFcxx . . $ QTWTF/::dayInMonthFromDayInYearcxx . . $ QTWTF/dayInMonthFromDayInYear(d455ce14f374a3ab).; |
| 121 | using WTFcxx . . $ `<built-in>:467:9`!::dayInYearcxx . . $ QTWTF/dayInYear(73c075bbbf02e8eb).; |
| 122 | using WTFcxx . . $ QTWTF/::minutesPerHourcxx . . $ minutesPerHour.; |
| 123 | using WTFcxx . . $ `<built-in>:467:9`!::monthFromDayInYearcxx . . $ monthFromDayInYear(d455ce14f374a3ab).; |
| 124 | using WTFcxx . . $ QTWTF/::msPerDaycxx . . $ QTWTF/msPerDay.; |
| 125 | using WTFcxx . . $ `<built-in>:467:9`!::msPerSecondcxx . . $ msPerSecond.; |
| 126 | using WTFcxx . . $ QTWTF/::msToYearcxx . . $ QTWTF/msToYear(620b9ac44d2573a6).; |
| 127 | using WTFcxx . . $ QTWTF/::secondsPerMinutecxx . . $ secondsPerMinute.; |
| 128 | using WTFcxx . . $ `<built-in>:467:9`!::LocalTimeOffsetcxx . . $ QTWTF/LocalTimeOffset#; |
| 129 | using WTFcxx . . $ QTWTF/::calculateLocalTimeOffsetcxx . . $ calculateLocalTimeOffset(1c25f9c1a4fcccfc).; |
| 130 | |
| 131 | #if USEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:55:9`!(JSC) |
| 132 | namespace JSCcxx . . $ QTJSC/ { |
| 133 | class ExecStatecxx . . $ QTJSC/ExecState#; |
| 134 | struct GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#; |
| 135 | |
| 136 | void msToGregorianDateTimecxx . . $ QTJSC/msToGregorianDateTime(5de9dac720d4db69).(ExecStatecxx . . $ QTJSC/ExecState#*, double, bool outputIsUTC, GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#&); |
| 137 | double gregorianDateTimeToMScxx . . $ QTJSC/gregorianDateTimeToMS(cc17aa427b3e2ce3).(ExecStatecxx . . $ QTJSC/ExecState#*, const GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#&, double, bool inputIsUTC); |
| 138 | double getUTCOffsetcxx . . $ QTJSC/getUTCOffset(ff55ebeb238fa2ae).(ExecStatecxx . . $ QTJSC/ExecState#*); |
| 139 | double parseDateFromNullTerminatedCharacterscxx . . $ QTJSC/parseDateFromNullTerminatedCharacters(e1ee60001899bbeb).(ExecStatecxx . . $ QTJSC/ExecState#*, const char* dateString); |
| 140 | |
| 141 | // Intentionally overridding the default tm of the system. |
| 142 | // The members of tm differ on various operating systems. |
| 143 | struct GregorianDateTimecxx . . $ QTJSC/GregorianDateTime# : Noncopyablecxx . . $ Noncopyable# { |
| 144 | GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#GregorianDateTime(49f6e7a06ebc5aa8).() |
| 145 | : secondcxx . . $ QTJSC/GregorianDateTime#second.(0) |
| 146 | , minutecxx . . $ QTJSC/GregorianDateTime#minute.(0) |
| 147 | , hourcxx . . $ QTJSC/GregorianDateTime#hour.(0) |
| 148 | , weekDaycxx . . $ QTJSC/GregorianDateTime#weekDay.(0) |
| 149 | , monthDaycxx . . $ QTJSC/GregorianDateTime#monthDay.(0) |
| 150 | , yearDaycxx . . $ QTJSC/GregorianDateTime#yearDay.(0) |
| 151 | , monthcxx . . $ QTJSC/GregorianDateTime#month.(0) |
| 152 | , yearcxx . . $ QTJSC/GregorianDateTime#year.(0) |
| 153 | , isDSTcxx . . $ QTJSC/GregorianDateTime#isDST.(0) |
| 154 | , utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset.(0) |
| 155 | , timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.(0) |
| 156 | { |
| 157 | } |
| 158 | |
| 159 | ~cxx . . $ QTJSC/GregorianDateTime#`~GregorianDateTime`(49f6e7a06ebc5aa8).GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#() |
| 160 | { |
| 161 | delete [] timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.; |
| 162 | } |
| 163 | |
| 164 | operatorcxx . . $ QTJSC/GregorianDateTime#`operator tm`(231edf2dcad4bc2a). tmcxx . . $ tm#() const |
| 165 | { |
| 166 | tmcxx . . $ tm# ret; |
| 167 | memset(&ret, 0, sizeof(ret)); |
| 168 | |
| 169 | ret.tm_seccxx . . $ tm#tm_sec. = secondcxx . . $ QTJSC/GregorianDateTime#second.; |
| 170 | ret.tm_mincxx . . $ tm#tm_min. = minutecxx . . $ QTJSC/GregorianDateTime#minute.; |
| 171 | ret.tm_hourcxx . . $ tm#tm_hour. = hourcxx . . $ QTJSC/GregorianDateTime#hour.; |
| 172 | ret.tm_wdaycxx . . $ tm#tm_wday. = weekDaycxx . . $ QTJSC/GregorianDateTime#weekDay.; |
| 173 | ret.tm_mdaycxx . . $ tm#tm_mday. = monthDaycxx . . $ QTJSC/GregorianDateTime#monthDay.; |
| 174 | ret.tm_ydaycxx . . $ tm#tm_yday. = yearDaycxx . . $ QTJSC/GregorianDateTime#yearDay.; |
| 175 | ret.tm_moncxx . . $ tm#tm_mon. = monthcxx . . $ QTJSC/GregorianDateTime#month.; |
| 176 | ret.tm_yearcxx . . $ tm#tm_year. = yearcxx . . $ QTJSC/GregorianDateTime#year.; |
| 177 | ret.tm_isdstcxx . . $ tm#tm_isdst. = isDSTcxx . . $ QTJSC/GregorianDateTime#isDST.; |
| 178 | |
| 179 | #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(TM_GMTOFF) |
| 180 | ret.tm_gmtoffcxx . . $ tm#tm_gmtoff. = static_cast<long>(utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset.); |
| 181 | #endif |
| 182 | #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(TM_ZONE) |
| 183 | ret.tm_zonecxx . . $ tm#tm_zone. = timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.; |
| 184 | #endif |
| 185 | |
| 186 | return ret; |
| 187 | } |
| 188 | |
| 189 | void copyFromcxx . . $ QTJSC/GregorianDateTime#copyFrom(2da595b959312da8).(const GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#& rhs) |
| 190 | { |
| 191 | secondcxx . . $ QTJSC/GregorianDateTime#second. = rhs.secondcxx . . $ QTJSC/GregorianDateTime#second.; |
| 192 | minutecxx . . $ QTJSC/GregorianDateTime#minute. = rhs.minutecxx . . $ QTJSC/GregorianDateTime#minute.; |
| 193 | hourcxx . . $ QTJSC/GregorianDateTime#hour. = rhs.hourcxx . . $ QTJSC/GregorianDateTime#hour.; |
| 194 | weekDaycxx . . $ QTJSC/GregorianDateTime#weekDay. = rhs.weekDaycxx . . $ QTJSC/GregorianDateTime#weekDay.; |
| 195 | monthDaycxx . . $ QTJSC/GregorianDateTime#monthDay. = rhs.monthDaycxx . . $ QTJSC/GregorianDateTime#monthDay.; |
| 196 | yearDaycxx . . $ QTJSC/GregorianDateTime#yearDay. = rhs.yearDaycxx . . $ QTJSC/GregorianDateTime#yearDay.; |
| 197 | monthcxx . . $ QTJSC/GregorianDateTime#month. = rhs.monthcxx . . $ QTJSC/GregorianDateTime#month.; |
| 198 | yearcxx . . $ QTJSC/GregorianDateTime#year. = rhs.yearcxx . . $ QTJSC/GregorianDateTime#year.; |
| 199 | isDSTcxx . . $ QTJSC/GregorianDateTime#isDST. = rhs.isDSTcxx . . $ QTJSC/GregorianDateTime#isDST.; |
| 200 | utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset. = rhs.utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset.; |
| 201 | if (rhs.timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.) { |
| 202 | int inZoneSize = strlen(rhs.timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.) + 1; |
| 203 | timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone. = new char[inZoneSize]; |
| 204 | strncpy(timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone., rhs.timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone., inZoneSize); |
| 205 | } else |
| 206 | timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone. = 0; |
| 207 | } |
| 208 | |
| 209 | int secondcxx . . $ QTJSC/GregorianDateTime#second.; |
| 210 | int minutecxx . . $ QTJSC/GregorianDateTime#minute.; |
| 211 | int hourcxx . . $ QTJSC/GregorianDateTime#hour.; |
| 212 | int weekDaycxx . . $ QTJSC/GregorianDateTime#weekDay.; |
| 213 | int monthDaycxx . . $ QTJSC/GregorianDateTime#monthDay.; |
| 214 | int yearDaycxx . . $ QTJSC/GregorianDateTime#yearDay.; |
| 215 | int monthcxx . . $ QTJSC/GregorianDateTime#month.; |
| 216 | int yearcxx . . $ QTJSC/GregorianDateTime#year.; |
| 217 | int isDSTcxx . . $ QTJSC/GregorianDateTime#isDST.; |
| 218 | int utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset.; |
| 219 | char* timeZonecxx . . $ QTJSC/GregorianDateTime#timeZone.; |
| 220 | }; |
| 221 | |
| 222 | static inline int gmtoffsetcxx . . $ QTJSC/gmtoffset(707d7e193f3ddb28).(const GregorianDateTimecxx . . $ QTJSC/GregorianDateTime#& t) |
| 223 | { |
| 224 | return t.utcOffsetcxx . . $ QTJSC/GregorianDateTime#utcOffset.; |
| 225 | } |
| 226 | } // namespace JSC |
| 227 | #endif // USE(JSC) |
| 228 | |
| 229 | #endif // DateMath_h |