Files
palemoon27/dom/bindings/Date.cpp
T
roytam1 20d9ef8894 import changes from `dev' branch of rmottola/Arctic-Fox:
- Pointer style (123e601e8)
- fix typo (609acf15f)
- Bug 1175538 - Ensure str_split result object has the right group. r=jandem (a2831dfea)
- Bug 1173100 - Cleanup OneUcs4ToUtf8Char a bit. r=Waldo (330503e3c)
- Bug 1199887 - Rename StringRegExpGuard::init(JSContext*, JSObject*) to initRegExp for clarity. r=evilpie (dd3b8bdc7)
- Bug 1199887 - Make str_replace_regexp_raw return a JSString*, rather than return its always-string result via outparam. r=evilpie (45f062b55)
- Bug 1199887 - Make str_replace_string_raw return a JSString*, rather than return its always-string result via outparam. r=evilpie (bc1d1f089)
- Bug 1139696 - Fix cross-compartment Map/Set structured cloning (r=evilpie) (97b6b3da2)
- Bug 789589 - Fix the ABO class hierarchy comment to be accurate, r=Waldo (88fb94723)
- Bug 789589 - Implement JS_NewDataView, r=Waldo (a6bbea944)
- Bug 789594 - Implement DataView cloning, r=Waldo (41ad7b157)
- Bug 1188612 - Transferable errors should become NS_DOM_DATA_CLONE_ERR, r=sfink (bdbf67c65)
- Bug 1179003 - Convert the infallible objectClassIs proxy hook into a fallible getBuiltinClass hook that indicates class type via outparam. r=efaust, r=bz on DOM bits, r=billm on IPC bits (61495dcc5)
- Bug 1191570 - Use ToPropertyKey everywhere ES6 says to use it. r=Waldo, r=jandem. (819417dea)
- Bug 1133377 - Make DataView constructor correctly handle undefined byteLength argument r=sfink (0fc942ba5)
- Bug 1199643 - Fix unsafe use of PerformanceGroup. r=jandem (2632d9f5d)
2021-11-18 10:36:15 +08:00

50 lines
1.3 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/Date.h"
#include "jsapi.h" // for JS_ObjectIsDate
#include "jsfriendapi.h" // for DateGetMsecSinceEpoch
#include "js/Date.h" // for JS::NewDateObject, JS::ClippedTime, JS::TimeClip
#include "js/RootingAPI.h" // for Rooted, MutableHandle
#include "js/Value.h" // for Value
#include "mozilla/FloatingPoint.h" // for IsNaN, UnspecifiedNaN
namespace mozilla {
namespace dom {
bool
Date::SetTimeStamp(JSContext* aCx, JSObject* aObject)
{
JS::Rooted<JSObject*> obj(aCx, aObject);
double msecs;
if (!js::DateGetMsecSinceEpoch(aCx, obj, &msecs)) {
return false;
}
JS::ClippedTime time = JS::TimeClip(msecs);
MOZ_ASSERT(NumbersAreIdentical(msecs, time.toDouble()));
mMsecSinceEpoch = time;
return true;
}
bool
Date::ToDateObject(JSContext* aCx, JS::MutableHandle<JS::Value> aRval) const
{
JSObject* obj = JS::NewDateObject(aCx, mMsecSinceEpoch);
if (!obj) {
return false;
}
aRval.setObject(*obj);
return true;
}
} // namespace dom
} // namespace mozilla