1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * vim: set ts=8 sts=4 et sw=4 tw=99:
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 /*
8  * JS Date class interface.
9  */
10 
11 #ifndef jsdate_h
12 #define jsdate_h
13 
14 #include "jstypes.h"
15 
16 #include "js/Date.h"
17 #include "js/RootingAPI.h"
18 #include "js/TypeDecls.h"
19 
20 #include "vm/DateTime.h"
21 
22 namespace js {
23 
24 /*
25  * These functions provide a C interface to the date/time object
26  */
27 
28 /*
29  * Construct a new Date Object from a time value given in milliseconds UTC
30  * since the epoch.
31  */
32 extern JSObject*
33 NewDateObjectMsec(JSContext* cx, JS::ClippedTime t, JS::HandleObject proto = nullptr);
34 
35 /*
36  * Construct a new Date Object from an exploded local time value.
37  *
38  * Assert that mon < 12 to help catch off-by-one user errors, which are common
39  * due to the 0-based month numbering copied into JS from Java (java.util.Date
40  * in 1995).
41  */
42 extern JS_FRIEND_API(JSObject*)
43 NewDateObject(JSContext* cx, int year, int mon, int mday,
44               int hour, int min, int sec);
45 
46 /* Date constructor native. Exposed only so the JIT can know its address. */
47 bool
48 DateConstructor(JSContext* cx, unsigned argc, JS::Value* vp);
49 
50 /* Date methods exposed so they can be installed in the self-hosting global. */
51 bool
52 date_now(JSContext* cx, unsigned argc, JS::Value* vp);
53 
54 bool
55 date_valueOf(JSContext* cx, unsigned argc, JS::Value* vp);
56 
57 } /* namespace js */
58 
59 #endif /* jsdate_h */
60