michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef vm_DateObject_h_ michael@0: #define vm_DateObject_h_ michael@0: michael@0: #include "jsobj.h" michael@0: michael@0: #include "js/Value.h" michael@0: michael@0: namespace js { michael@0: michael@0: class DateTimeInfo; michael@0: michael@0: class DateObject : public JSObject michael@0: { michael@0: static const uint32_t UTC_TIME_SLOT = 0; michael@0: static const uint32_t TZA_SLOT = 1; michael@0: michael@0: /* michael@0: * Cached slots holding local properties of the date. michael@0: * These are undefined until the first actual lookup occurs michael@0: * and are reset to undefined whenever the date's time is modified. michael@0: */ michael@0: static const uint32_t COMPONENTS_START_SLOT = 2; michael@0: michael@0: static const uint32_t LOCAL_TIME_SLOT = COMPONENTS_START_SLOT + 0; michael@0: static const uint32_t LOCAL_YEAR_SLOT = COMPONENTS_START_SLOT + 1; michael@0: static const uint32_t LOCAL_MONTH_SLOT = COMPONENTS_START_SLOT + 2; michael@0: static const uint32_t LOCAL_DATE_SLOT = COMPONENTS_START_SLOT + 3; michael@0: static const uint32_t LOCAL_DAY_SLOT = COMPONENTS_START_SLOT + 4; michael@0: static const uint32_t LOCAL_HOURS_SLOT = COMPONENTS_START_SLOT + 5; michael@0: static const uint32_t LOCAL_MINUTES_SLOT = COMPONENTS_START_SLOT + 6; michael@0: static const uint32_t LOCAL_SECONDS_SLOT = COMPONENTS_START_SLOT + 7; michael@0: michael@0: static const uint32_t RESERVED_SLOTS = LOCAL_SECONDS_SLOT + 1; michael@0: michael@0: public: michael@0: static const Class class_; michael@0: michael@0: inline const js::Value &UTCTime() const { michael@0: return getFixedSlot(UTC_TIME_SLOT); michael@0: } michael@0: michael@0: // Set UTC time to a given time and invalidate cached local time. michael@0: void setUTCTime(double t, Value *vp = nullptr); michael@0: michael@0: inline double cachedLocalTime(DateTimeInfo *dtInfo); michael@0: michael@0: // Cache the local time, year, month, and so forth of the object. michael@0: // If UTC time is not finite (e.g., NaN), the local time michael@0: // slots will be set to the UTC time without conversion. michael@0: void fillLocalTimeSlots(DateTimeInfo *dtInfo); michael@0: michael@0: static MOZ_ALWAYS_INLINE bool getTime_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getYear_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getFullYear_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCFullYear_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getMonth_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCMonth_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getDate_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCDate_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getDay_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCDay_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getHours_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCHours_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getMinutes_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCMinutes_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCSeconds_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getUTCMilliseconds_impl(JSContext *cx, CallArgs args); michael@0: static MOZ_ALWAYS_INLINE bool getTimezoneOffset_impl(JSContext *cx, CallArgs args); michael@0: }; michael@0: michael@0: } // namespace js michael@0: michael@0: #endif // vm_DateObject_h_