Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/bindings/Date.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/Date.h"
8
9
#include "jsapi.h" // for JS_ObjectIsDate
10
#include "jsfriendapi.h" // for DateGetMsecSinceEpoch
11
#include "js/Date.h" // for JS::NewDateObject, JS::ClippedTime, JS::TimeClip
12
#include "js/RootingAPI.h" // for Rooted, MutableHandle
13
#include "js/Value.h" // for Value
14
#include "mozilla/FloatingPoint.h" // for IsNaN, UnspecifiedNaN
15
16
namespace mozilla {
17
namespace dom {
18
19
bool
20
Date::SetTimeStamp(JSContext* aCx, JSObject* aObject)
21
0
{
22
0
  JS::Rooted<JSObject*> obj(aCx, aObject);
23
0
24
0
  double msecs;
25
0
  if (!js::DateGetMsecSinceEpoch(aCx, obj, &msecs)) {
26
0
    return false;
27
0
  }
28
0
29
0
  JS::ClippedTime time = JS::TimeClip(msecs);
30
0
  MOZ_ASSERT(NumbersAreIdentical(msecs, time.toDouble()));
31
0
32
0
  mMsecSinceEpoch = time;
33
0
  return true;
34
0
}
35
36
bool
37
Date::ToDateObject(JSContext* aCx, JS::MutableHandle<JS::Value> aRval) const
38
0
{
39
0
  JSObject* obj = JS::NewDateObject(aCx, mMsecSinceEpoch);
40
0
  if (!obj) {
41
0
    return false;
42
0
  }
43
0
44
0
  aRval.setObject(*obj);
45
0
  return true;
46
0
}
47
48
} // namespace dom
49
} // namespace mozilla