Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/Date.h
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
/* Representation for dates. */
8
9
#ifndef mozilla_dom_Date_h
10
#define mozilla_dom_Date_h
11
12
#include "js/Date.h"
13
#include "js/TypeDecls.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
class Date
19
{
20
public:
21
0
  Date() {}
22
  explicit Date(JS::ClippedTime aMilliseconds)
23
    : mMsecSinceEpoch(aMilliseconds)
24
0
  {}
25
26
  bool IsUndefined() const
27
0
  {
28
0
    return !mMsecSinceEpoch.isValid();
29
0
  }
30
31
  JS::ClippedTime TimeStamp() const
32
0
  {
33
0
    return mMsecSinceEpoch;
34
0
  }
35
36
  // Returns an integer in the range [-8.64e15, +8.64e15] (-0 excluded), *or*
37
  // returns NaN.  DO NOT ASSUME THIS IS FINITE!
38
  double ToDouble() const
39
0
  {
40
0
    return mMsecSinceEpoch.toDouble();
41
0
  }
42
43
  void SetTimeStamp(JS::ClippedTime aMilliseconds)
44
0
  {
45
0
    mMsecSinceEpoch = aMilliseconds;
46
0
  }
47
48
  // Can return false if CheckedUnwrap fails.  This will NOT throw;
49
  // callers should do it as needed.
50
  bool SetTimeStamp(JSContext* aCx, JSObject* aObject);
51
52
  bool ToDateObject(JSContext* aCx, JS::MutableHandle<JS::Value> aRval) const;
53
54
private:
55
  JS::ClippedTime mMsecSinceEpoch;
56
};
57
58
} // namespace dom
59
} // namespace mozilla
60
61
#endif // mozilla_dom_Date_h