jsduck 3.0.pre → 3.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +21 -229
- data/Rakefile +31 -17
- data/bin/jsduck +1 -0
- data/js-classes/Array.js +561 -0
- data/js-classes/Boolean.js +110 -0
- data/js-classes/Date.js +999 -0
- data/js-classes/Function.js +256 -0
- data/js-classes/Number.js +308 -0
- data/js-classes/Object.js +404 -0
- data/js-classes/RegExp.js +415 -0
- data/js-classes/String.js +1034 -0
- data/jsduck.gemspec +2 -2
- data/lib/jsduck/accessors.rb +71 -0
- data/lib/jsduck/aggregator.rb +14 -2
- data/lib/jsduck/app.rb +6 -5
- data/lib/jsduck/class_formatter.rb +12 -8
- data/lib/jsduck/css_parser.rb +2 -2
- data/lib/jsduck/doc_formatter.rb +2 -2
- data/lib/jsduck/doc_parser.rb +32 -25
- data/lib/jsduck/exporter.rb +1 -1
- data/lib/jsduck/guides.rb +11 -2
- data/lib/jsduck/js_parser.rb +30 -8
- data/lib/jsduck/merger.rb +31 -16
- data/lib/jsduck/options.rb +93 -15
- data/lib/jsduck/renderer.rb +40 -3
- data/lib/jsduck/search_data.rb +8 -5
- data/lib/jsduck/source_file.rb +5 -4
- data/lib/jsduck/type_parser.rb +7 -6
- metadata +17 -5
- data/example.js +0 -144
@@ -0,0 +1,110 @@
|
|
1
|
+
/**
|
2
|
+
* @class Boolean
|
3
|
+
*
|
4
|
+
* The `Boolean` object is an object wrapper for a boolean value.
|
5
|
+
*
|
6
|
+
* The value passed as the first parameter is converted to a boolean value, if necessary. If value is
|
7
|
+
* omitted or is 0, -0, null, false, `NaN`, undefined, or the empty string (""), the object has an
|
8
|
+
* initial value of false. All other values, including any object or the string `"false"`, create an
|
9
|
+
* object with an initial value of true.
|
10
|
+
*
|
11
|
+
* Do not confuse the primitive Boolean values true and false with the true and false values of the
|
12
|
+
* Boolean object.
|
13
|
+
*
|
14
|
+
* Any object whose value is not `undefined` or `null`, including a Boolean object whose value is false,
|
15
|
+
* evaluates to true when passed to a conditional statement. For example, the condition in the following
|
16
|
+
* if statement evaluates to true:
|
17
|
+
*
|
18
|
+
* x = new Boolean(false);
|
19
|
+
* if (x) {
|
20
|
+
* // . . . this code is executed
|
21
|
+
* }
|
22
|
+
*
|
23
|
+
* This behavior does not apply to Boolean primitives. For example, the condition in the following if
|
24
|
+
* statement evaluates to `false`:
|
25
|
+
* x = false;
|
26
|
+
* if (x) {
|
27
|
+
* // . . . this code is not executed
|
28
|
+
* }
|
29
|
+
*
|
30
|
+
* Do not use a `Boolean` object to convert a non-boolean value to a boolean value. Instead, use Boolean
|
31
|
+
* as a function to perform this task:
|
32
|
+
*
|
33
|
+
* x = Boolean(expression); // preferred
|
34
|
+
* x = new Boolean(expression); // don't use
|
35
|
+
*
|
36
|
+
* If you specify any object, including a Boolean object whose value is false, as the initial value of a
|
37
|
+
* Boolean object, the new Boolean object has a value of true.
|
38
|
+
*
|
39
|
+
* myFalse = new Boolean(false); // initial value of false
|
40
|
+
* g = new Boolean(myFalse); // initial value of true
|
41
|
+
* myString = new String("Hello"); // string object
|
42
|
+
* s = new Boolean(myString); // initial value of true
|
43
|
+
*
|
44
|
+
* Do not use a Boolean object in place of a Boolean primitive.
|
45
|
+
*
|
46
|
+
* # Creating Boolean objects with an initial value of false
|
47
|
+
*
|
48
|
+
* bNoParam = new Boolean();
|
49
|
+
* bZero = new Boolean(0);
|
50
|
+
* bNull = new Boolean(null);
|
51
|
+
* bEmptyString = new Boolean("");
|
52
|
+
* bfalse = new Boolean(false);
|
53
|
+
*
|
54
|
+
* # Creating Boolean objects with an initial value of true
|
55
|
+
*
|
56
|
+
* btrue = new Boolean(true);
|
57
|
+
* btrueString = new Boolean("true");
|
58
|
+
* bfalseString = new Boolean("false");
|
59
|
+
* bSuLin = new Boolean("Su Lin");
|
60
|
+
*
|
61
|
+
* <div class="notice">
|
62
|
+
* Documentation for this class comes from <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean">MDN</a>
|
63
|
+
* and is available under <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons: Attribution-Sharealike license</a>.
|
64
|
+
* </div>
|
65
|
+
*/
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @method constructor
|
69
|
+
* Creates a new boolean object.
|
70
|
+
* @param {Object} value Either a truthy or falsy value to create the corresponding Boolean object.
|
71
|
+
*/
|
72
|
+
|
73
|
+
//Methods
|
74
|
+
|
75
|
+
/**
|
76
|
+
* @method toString
|
77
|
+
* Returns a string of either "true" or "false" depending upon the value of the object.
|
78
|
+
* Overrides the `Object.prototype.toString` method.
|
79
|
+
*
|
80
|
+
* The Boolean object overrides the `toString` method of the `Object` object; it does not inherit
|
81
|
+
* `Object.toString`. For Boolean objects, the `toString` method returns a string representation of
|
82
|
+
* the object.
|
83
|
+
*
|
84
|
+
* JavaScript calls the `toString` method automatically when a Boolean is to be represented as a text
|
85
|
+
* value or when a Boolean is referred to in a string concatenation.
|
86
|
+
*
|
87
|
+
* For Boolean objects and values, the built-in `toString` method returns the string `"true"` or
|
88
|
+
* `"false"` depending on the value of the boolean object. In the following code, `flag.toString`
|
89
|
+
* returns `"true"`.
|
90
|
+
*
|
91
|
+
* var flag = new Boolean(true)
|
92
|
+
* var myVar = flag.toString()
|
93
|
+
*
|
94
|
+
* @return {String} The boolean value represented as a string.
|
95
|
+
*/
|
96
|
+
|
97
|
+
/**
|
98
|
+
* @method valueOf
|
99
|
+
* Returns the primitive value of the `Boolean` object. Overrides the `Object.prototype.valueOf` method.
|
100
|
+
*
|
101
|
+
* The `valueOf` method of Boolean returns the primitive value of a Boolean object or literal Boolean
|
102
|
+
* as a Boolean data type.
|
103
|
+
*
|
104
|
+
* This method is usually called internally by JavaScript and not explicitly in code.
|
105
|
+
*
|
106
|
+
* x = new Boolean();
|
107
|
+
* myVar = x.valueOf() //assigns false to myVar
|
108
|
+
*
|
109
|
+
* @return {Boolean} The primitive value.
|
110
|
+
*/
|
data/js-classes/Date.js
ADDED
@@ -0,0 +1,999 @@
|
|
1
|
+
/**
|
2
|
+
* @class Date
|
3
|
+
*
|
4
|
+
* Creates `Date` instances which let you work with dates and times.
|
5
|
+
*
|
6
|
+
* If you supply no arguments, the constructor creates a `Date` object for today's
|
7
|
+
* date and time according to local time. If you supply some arguments but not
|
8
|
+
* others, the missing arguments are set to 0. If you supply any arguments, you
|
9
|
+
* must supply at least the year, month, and day. You can omit the hours, minutes,
|
10
|
+
* seconds, and milliseconds.
|
11
|
+
*
|
12
|
+
* The date is measured in milliseconds since midnight 01 January, 1970 UTC. A day
|
13
|
+
* holds 86,400,000 milliseconds. The `Date` object range is -100,000,000 days to
|
14
|
+
* 100,000,000 days relative to 01 January, 1970 UTC.
|
15
|
+
*
|
16
|
+
* The `Date` object provides uniform behavior across platforms.
|
17
|
+
*
|
18
|
+
* The `Date` object supports a number of UTC (universal) methods, as well as
|
19
|
+
* local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the
|
20
|
+
* time as set by the World Time Standard. The local time is the time known to the
|
21
|
+
* computer where JavaScript is executed.
|
22
|
+
*
|
23
|
+
* Invoking `Date` in a non-constructor context (i.e., without the `new` operator)
|
24
|
+
* will return a string representing the current time.
|
25
|
+
*
|
26
|
+
* Note that `Date` objects can only be instantiated by calling `Date` or using it
|
27
|
+
* as a constructor; unlike other JavaScript object types, `Date` objects have no
|
28
|
+
* literal syntax.
|
29
|
+
*
|
30
|
+
* # Several ways to assign dates
|
31
|
+
*
|
32
|
+
* The following example shows several ways to assign dates:
|
33
|
+
*
|
34
|
+
* today = new Date();
|
35
|
+
* birthday = new Date("December 19, 1989 03:24:00");
|
36
|
+
* birthday = new Date(1989,11,19);
|
37
|
+
* birthday = new Date(1989,11,17,3,24,0);
|
38
|
+
*
|
39
|
+
* # Calculating elapsed time
|
40
|
+
*
|
41
|
+
* The following examples show how to determine the elapsed time between two dates:
|
42
|
+
*
|
43
|
+
* // using static methods
|
44
|
+
* var start = Date.now();
|
45
|
+
* // the event you'd like to time goes here:
|
46
|
+
* doSomethingForALongTime();
|
47
|
+
* var end = Date.now();
|
48
|
+
* var elapsed = end - start; // time in milliseconds
|
49
|
+
*
|
50
|
+
* // if you have Date objects
|
51
|
+
* var start = new Date();
|
52
|
+
* // the event you'd like to time goes here:
|
53
|
+
* doSomethingForALongTime();
|
54
|
+
* var end = new Date();
|
55
|
+
* var elapsed = end.getTime() - start.getTime(); // time in milliseconds
|
56
|
+
*
|
57
|
+
* // if you want to test a function and get back its return
|
58
|
+
* function printElapsedTime (fTest) {
|
59
|
+
* var nStartTime = Date.now(), vReturn = fTest(), nEndTime = Date.now();
|
60
|
+
* alert("Elapsed time: " + String(nEndTime - nStartTime) + "
|
61
|
+
* milliseconds");
|
62
|
+
* return vReturn;
|
63
|
+
* }
|
64
|
+
*
|
65
|
+
* yourFunctionReturn = printElapsedTime(yourFunction);
|
66
|
+
*
|
67
|
+
* # ISO 8601 formatted dates
|
68
|
+
*
|
69
|
+
* The following example shows how to formate a date in an ISO 8601 format using
|
70
|
+
* UTC:
|
71
|
+
*
|
72
|
+
* // use a function for the exact format desired...
|
73
|
+
* function ISODateString(d){
|
74
|
+
* function pad(n){return n<10 ? '0'+n : n}
|
75
|
+
* return d.getUTCFullYear()+'-'
|
76
|
+
* + pad(d.getUTCMonth()+1)+'-'
|
77
|
+
* + pad(d.getUTCDate())+'T'
|
78
|
+
* + pad(d.getUTCHours())+':'
|
79
|
+
* + pad(d.getUTCMinutes())+':'
|
80
|
+
* + pad(d.getUTCSeconds())+'Z'}
|
81
|
+
*
|
82
|
+
* var d = new Date();
|
83
|
+
* print(ISODateString(d)); // prints something like 2009-09-28T19:03:12Z
|
84
|
+
*
|
85
|
+
* <div class="notice">
|
86
|
+
* Documentation for this class comes from <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">MDN</a>
|
87
|
+
* and is available under <a href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons: Attribution-Sharealike license</a>.
|
88
|
+
* </div>
|
89
|
+
*/
|
90
|
+
|
91
|
+
/**
|
92
|
+
* @method constructor
|
93
|
+
* Creates new Date object.
|
94
|
+
*
|
95
|
+
* @param {Number/String} [year]
|
96
|
+
* Either UNIX timestamp, date string, or year (when month and day parameters also provided):
|
97
|
+
*
|
98
|
+
* - Integer value representing the number of milliseconds since 1 January 1970
|
99
|
+
* 00:00:00 UTC (Unix Epoch).
|
100
|
+
*
|
101
|
+
* - String value representing a date. The string should be in a format recognized
|
102
|
+
* by the parse method (IETF-compliant RFC 1123 timestamps).
|
103
|
+
*
|
104
|
+
* - Integer value representing the year. For compatibility (in order to avoid the
|
105
|
+
* Y2K problem), you should always specify the year in full; use 1998, rather
|
106
|
+
* than 98.
|
107
|
+
*
|
108
|
+
* @param {Number} [month]
|
109
|
+
* Integer value representing the month, beginning with 0 for January to 11
|
110
|
+
* for December.
|
111
|
+
* @param {Number} [day]
|
112
|
+
* Integer value representing the day of the month (1-31).
|
113
|
+
* @param {Number} [hour]
|
114
|
+
* Integer value representing the hour of the day (0-23).
|
115
|
+
* @param {Number} [minute]
|
116
|
+
* Integer value representing the minute segment (0-59) of a time reading.
|
117
|
+
* @param {Number} [second]
|
118
|
+
* Integer value representing the second segment (0-59) of a time reading.
|
119
|
+
* @param {Number} [millisecond]
|
120
|
+
* Integer value representing the millisecond segment (0-999) of a time reading.
|
121
|
+
*/
|
122
|
+
|
123
|
+
|
124
|
+
//Methods
|
125
|
+
|
126
|
+
/**
|
127
|
+
* @method now
|
128
|
+
* @static
|
129
|
+
* Returns the numeric value corresponding to the current time.
|
130
|
+
*
|
131
|
+
* The `now` method returns the milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now as
|
132
|
+
* a number.
|
133
|
+
*
|
134
|
+
* When using `now` to create timestamps or unique IDs, keep in mind that the resolution may be 15
|
135
|
+
* milliseconds on Windows, so you could end up with several equal values if `now` is called multiple
|
136
|
+
* times within a short time span.
|
137
|
+
*
|
138
|
+
* @return {Number} Returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
|
139
|
+
*/
|
140
|
+
|
141
|
+
/**
|
142
|
+
* @method parse
|
143
|
+
* @static
|
144
|
+
* Parses a string representation of a date, and returns the number of milliseconds
|
145
|
+
* since January 1, 1970, 00:00:00, local time.
|
146
|
+
*
|
147
|
+
* The `parse` method takes a date string (such as `"Dec 25, 1995"`) and returns the number of
|
148
|
+
* milliseconds since January 1, 1970, 00:00:00 UTC. The local time zone is used to interpret
|
149
|
+
* arguments that do not contain time zone information. This function is useful for setting date
|
150
|
+
* values based on string values, for example in conjunction with the `setTime` method and the
|
151
|
+
* {@link Date} object.
|
152
|
+
*
|
153
|
+
* Given a string representing a time, parse returns the time value. It accepts the IETF standard (RFC
|
154
|
+
* 1123 Section 5.2.14 and elsewhere) date syntax: `"Mon, 25 Dec 1995 13:30:00 GMT"`. It understands
|
155
|
+
* the continental US time-zone abbreviations, but for general use, use a time-zone offset, for
|
156
|
+
* example, `"Mon, 25 Dec 1995 13:30:00 GMT+0430"` (4 hours, 30 minutes east of the Greenwich
|
157
|
+
* meridian). If you do not specify a time zone, the local time zone is assumed. GMT and UTC are
|
158
|
+
* considered equivalent.
|
159
|
+
*
|
160
|
+
* ### Using parse
|
161
|
+
*
|
162
|
+
* If `IPOdate` is an existing `Date` object, then you can set it to August 9, 1995 (local time) as
|
163
|
+
* follows:
|
164
|
+
*
|
165
|
+
* IPOdate.setTime(Date.parse("Aug 9, 1995"));
|
166
|
+
*
|
167
|
+
* Some other examples:
|
168
|
+
*
|
169
|
+
* // Returns 807937200000 in time zone GMT-0300, and other values in other
|
170
|
+
* // timezones, since the argument does not specify a time zone.
|
171
|
+
* Date.parse("Aug 9, 1995");
|
172
|
+
*
|
173
|
+
* // Returns 807926400000 no matter the local time zone.
|
174
|
+
* Date.parse("Wed, 09 Aug 1995 00:00:00 GMT");
|
175
|
+
*
|
176
|
+
* // Returns 807937200000 in timezone GMT-0300, and other values in other
|
177
|
+
* // timezones, since there is no time zone specifier in the argument.
|
178
|
+
* Date.parse("Wed, 09 Aug 1995 00:00:00");
|
179
|
+
*
|
180
|
+
* // Returns 0 no matter the local time zone.
|
181
|
+
* Date.parse("Thu, 01 Jan 1970 00:00:00 GMT");
|
182
|
+
*
|
183
|
+
* // Returns 14400000 in timezone GMT-0400, and other values in other
|
184
|
+
* // timezones, since there is no time zone specifier in the argument.
|
185
|
+
* Date.parse("Thu, 01 Jan 1970 00:00:00");
|
186
|
+
*
|
187
|
+
* // Returns 14400000 no matter the local time zone.
|
188
|
+
* Date.parse("Thu, 01 Jan 1970 00:00:00 GMT-0400");
|
189
|
+
*
|
190
|
+
* @param {String} dateString A string representing a date.
|
191
|
+
* @return {Number} Number of milliseconds since January 1, 1970, 00:00:00, local time.
|
192
|
+
*/
|
193
|
+
|
194
|
+
/**
|
195
|
+
* @method UTC
|
196
|
+
* @static
|
197
|
+
* Accepts the same parameters as the longest form of the constructor, and returns
|
198
|
+
* the number of milliseconds in a `Date` object since January 1, 1970, 00:00:00,
|
199
|
+
* universal time.
|
200
|
+
*
|
201
|
+
* `UTC` takes comma-delimited date parameters and returns the number of milliseconds between January
|
202
|
+
* 1, 1970, 00:00:00, universal time and the time you specified.
|
203
|
+
*
|
204
|
+
* You should specify a full year for the year; for example, 1998. If a year between 0 and 99 is
|
205
|
+
* specified, the method converts the year to a year in the 20th century (1900 + year); for example,
|
206
|
+
* if you specify 95, the year 1995 is used.
|
207
|
+
*
|
208
|
+
* The `UTC` method differs from the `Date` constructor in two ways.
|
209
|
+
* * `Date.UTC` uses universal time instead of the local time.
|
210
|
+
* * `Date.UTC` returns a time value as a number instead of creating a `Date` object.
|
211
|
+
*
|
212
|
+
* If a parameter you specify is outside of the expected range, the `UTC` method updates the other
|
213
|
+
* parameters to allow for your number. For example, if you use 15 for month, the year will be
|
214
|
+
* incremented by 1 (year + 1), and 3 will be used for the month.
|
215
|
+
*
|
216
|
+
* Because `UTC` is a static method of `Date`, you always use it as `Date.UTC()`, rather than as a
|
217
|
+
* method of a `Date` object you created.
|
218
|
+
*
|
219
|
+
* The following statement creates a `Date` object using GMT instead of local time:
|
220
|
+
*
|
221
|
+
* gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0));
|
222
|
+
*
|
223
|
+
* @param {Number} year A year after 1900.
|
224
|
+
* @param {Number} month An integer between 0 and 11 representing the month.
|
225
|
+
* @param {Number} date An integer between 1 and 31 representing the day of the month.
|
226
|
+
* @param {Number} hrs An integer between 0 and 23 representing the hours.
|
227
|
+
* @param {Number} min An integer between 0 and 59 representing the minutes.
|
228
|
+
* @param {Number} sec An integer between 0 and 59 representing the seconds.
|
229
|
+
* @param {Number} ms An integer between 0 and 999 representing the milliseconds.
|
230
|
+
* @return {Date} Number of milliseconds since January 1, 1970, 00:00:00, universal time.
|
231
|
+
*/
|
232
|
+
|
233
|
+
//Methods
|
234
|
+
|
235
|
+
/**
|
236
|
+
* @method getDate
|
237
|
+
* Returns the numeric value corresponding to the current time.
|
238
|
+
*
|
239
|
+
* The second statement below assigns the value 25 to the variable `day`, based on the value of the
|
240
|
+
* `Date` object `Xmas95`.
|
241
|
+
*
|
242
|
+
* Xmas95 = new Date("December 25, 1995 23:15:00")
|
243
|
+
* day = Xmas95.getDate()
|
244
|
+
*
|
245
|
+
* @return {Number} Value between 1 and 31.
|
246
|
+
*/
|
247
|
+
|
248
|
+
/**
|
249
|
+
* @method getDay
|
250
|
+
* Returns the numeric value corresponding to the current time.
|
251
|
+
*
|
252
|
+
* The value returned by `getDay` is an integer corresponding to the day of the week: 0 for Sunday, 1
|
253
|
+
* for Monday, 2 for Tuesday, and so on.
|
254
|
+
*
|
255
|
+
* The second statement below assigns the value 1 to `weekday`, based on the value of the `Date`
|
256
|
+
* object `Xmas95`. December 25, 1995, is a Monday.
|
257
|
+
*
|
258
|
+
* Xmas95 = new Date("December 25, 1995 23:15:00");
|
259
|
+
* weekday = Xmas95.getDay();
|
260
|
+
*
|
261
|
+
* @return {Number} A numeric representation of the day from Sunday (0) to
|
262
|
+
* Saturday (6).
|
263
|
+
*/
|
264
|
+
|
265
|
+
/**
|
266
|
+
* @method getFullYear
|
267
|
+
* Returns the numeric value corresponding to the current time.
|
268
|
+
*
|
269
|
+
* The value returned by `getFullYear` is an absolute number. For dates between the years 1000 and
|
270
|
+
* 9999, `getFullYear` returns a four-digit number, for example, 1995. Use this function to make sure
|
271
|
+
* a year is compliant with years after 2000.
|
272
|
+
*
|
273
|
+
* Use this method instead of the `getYear` method.
|
274
|
+
*
|
275
|
+
* The following example assigns the four-digit value of the current year to the variable yr.
|
276
|
+
*
|
277
|
+
* var today = new Date();
|
278
|
+
* var yr = today.getFullYear();
|
279
|
+
*
|
280
|
+
* @return {Number} Four digit representation of the year.
|
281
|
+
*/
|
282
|
+
|
283
|
+
/**
|
284
|
+
* @method getHours
|
285
|
+
* Returns the numeric value corresponding to the current time.
|
286
|
+
*
|
287
|
+
* The second statement below assigns the value 23 to the variable `hours`, based on the value of the
|
288
|
+
* `Date` object `Xmas95`.
|
289
|
+
*
|
290
|
+
* Xmas95 = new Date("December 25, 1995 23:15:00")
|
291
|
+
* hours = Xmas95.getHours()
|
292
|
+
*
|
293
|
+
* @return {Number} Value between 0 and 23, using 24-hour clock.
|
294
|
+
*/
|
295
|
+
|
296
|
+
/**
|
297
|
+
* @method getMilliseconds
|
298
|
+
* Returns the numeric value corresponding to the current time.
|
299
|
+
*
|
300
|
+
* The following example assigns the milliseconds portion of the current time to the variable ms.
|
301
|
+
*
|
302
|
+
* var ms;
|
303
|
+
* Today = new Date();
|
304
|
+
* ms = Today.getMilliseconds();
|
305
|
+
*
|
306
|
+
* @return {Number} A number between 0 and 999.
|
307
|
+
*/
|
308
|
+
|
309
|
+
/**
|
310
|
+
* @method getMinutes
|
311
|
+
* Returns the numeric value corresponding to the current time.
|
312
|
+
*
|
313
|
+
* The second statement below assigns the value 15 to the variable `minutes`, based on the value of
|
314
|
+
* the `Date` object `Xmas95`.
|
315
|
+
*
|
316
|
+
* Xmas95 = new Date("December 25, 1995 23:15:00")
|
317
|
+
* minutes = Xmas95.getMinutes()
|
318
|
+
*
|
319
|
+
* @return {Number} Value between 0 and 59.
|
320
|
+
*/
|
321
|
+
|
322
|
+
/**
|
323
|
+
* @method getMonth
|
324
|
+
* Returns the numeric value corresponding to the current time.
|
325
|
+
*
|
326
|
+
* The second statement below assigns the value 11 to the variable `month`, based on the value of the
|
327
|
+
* `Date` object `Xmas95`.
|
328
|
+
*
|
329
|
+
* Xmas95 = new Date("December 25, 1995 23:15:00")
|
330
|
+
* month = Xmas95.getMonth()
|
331
|
+
*
|
332
|
+
* @return {Number} An integer between 0 and 11. 0 corresponds to January, 1 to February, and so on.
|
333
|
+
*/
|
334
|
+
|
335
|
+
/**
|
336
|
+
* @method getSeconds
|
337
|
+
* Returns the numeric value corresponding to the current time.
|
338
|
+
*
|
339
|
+
* The second statement below assigns the value 30 to the variable `secs`, based on the value of the
|
340
|
+
* `Date` object `Xmas95`.
|
341
|
+
*
|
342
|
+
* Xmas95 = new Date("December 25, 1995 23:15:30")
|
343
|
+
* secs = Xmas95.getSeconds()
|
344
|
+
*
|
345
|
+
* @return {Number} Value between 0 and 59.
|
346
|
+
*/
|
347
|
+
|
348
|
+
/**
|
349
|
+
* @method getTime
|
350
|
+
* Returns the numeric value corresponding to the current time.
|
351
|
+
*
|
352
|
+
* The value returned by the `getTime` method is the number of milliseconds since 1 January 1970
|
353
|
+
* 00:00:00 UTC. You can use this method to help assign a date and time to another `Date` object.
|
354
|
+
*
|
355
|
+
* This method is functionally equivalent to the `valueOf` method.
|
356
|
+
*
|
357
|
+
* Using getTime for copying dates
|
358
|
+
*
|
359
|
+
* Constructing a date object with the identical time value.
|
360
|
+
*
|
361
|
+
* var birthday = new Date(1994, 12, 10);
|
362
|
+
* var copy = new Date();
|
363
|
+
* copy.setTime(birthday.getTime());
|
364
|
+
*
|
365
|
+
* Measuring execution time
|
366
|
+
*
|
367
|
+
* Subtracting two subsequent getTime calls on newly generated Date objects, give the time span
|
368
|
+
* between these two calls. This can be used to calculate the executing time of some operations.
|
369
|
+
*
|
370
|
+
* var end, start;
|
371
|
+
*
|
372
|
+
* start = new Date();
|
373
|
+
* for (var i = 0; i < 1000; i++)
|
374
|
+
* Math.sqrt(i);
|
375
|
+
* end = new Date();
|
376
|
+
*
|
377
|
+
* console.log("Operation took " + (end.getTime() - start.getTime()) + " msec");
|
378
|
+
*
|
379
|
+
* @return {Number} Number of milliseconds since 1/1/1970 (GMT).
|
380
|
+
*/
|
381
|
+
|
382
|
+
/**
|
383
|
+
* @method getTimezoneOffset
|
384
|
+
* Returns the numeric value corresponding to the current time.
|
385
|
+
*
|
386
|
+
* The time-zone offset is the difference, in minutes, between UTC and local time. Note that this
|
387
|
+
* means that the offset is positive if the local timezone is behind UTC and negative if it is ahead.
|
388
|
+
* For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned.
|
389
|
+
* Daylight savings time prevents this value from being a constant even for a given locale
|
390
|
+
*
|
391
|
+
* x = new Date()
|
392
|
+
* currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60
|
393
|
+
*
|
394
|
+
* @return {Number} Minutes between GMT and local time.
|
395
|
+
*/
|
396
|
+
|
397
|
+
/**
|
398
|
+
* @method getUTCDate
|
399
|
+
* Returns the numeric value corresponding to the current time.
|
400
|
+
*
|
401
|
+
* The following example assigns the day portion of the current date to the variable `d`.
|
402
|
+
*
|
403
|
+
* var d;
|
404
|
+
* Today = new Date();
|
405
|
+
* d = Today.getUTCDate();
|
406
|
+
*
|
407
|
+
* @return {Number} Integer between 1 and 31 representing the day.
|
408
|
+
*/
|
409
|
+
|
410
|
+
/**
|
411
|
+
* @method getUTCDay
|
412
|
+
* Returns the numeric value corresponding to the current time.
|
413
|
+
*
|
414
|
+
* The following example assigns the weekday portion of the current date to the variable `weekday`.
|
415
|
+
*
|
416
|
+
* var weekday;
|
417
|
+
* Today = new Date()
|
418
|
+
* weekday = Today.getUTCDay()
|
419
|
+
*
|
420
|
+
* @return {Number} A numeric representation of the day from Sunday (0) to
|
421
|
+
* Saturday (6).
|
422
|
+
*/
|
423
|
+
|
424
|
+
/**
|
425
|
+
* @method getUTCFullYear
|
426
|
+
* Returns the numeric value corresponding to the current time.
|
427
|
+
*
|
428
|
+
* The following example assigns the four-digit value of the current year to the variable `yr`.
|
429
|
+
*
|
430
|
+
* var yr;
|
431
|
+
* Today = new Date();
|
432
|
+
* yr = Today.getUTCFullYear();
|
433
|
+
*
|
434
|
+
* @return {Number} Four digit representation of the year.
|
435
|
+
*/
|
436
|
+
|
437
|
+
/**
|
438
|
+
* @method getUTCHours
|
439
|
+
* Returns the numeric value corresponding to the current time.
|
440
|
+
*
|
441
|
+
* The following example assigns the hours portion of the current time to the variable `hrs`.
|
442
|
+
*
|
443
|
+
* var hrs;
|
444
|
+
* Today = new Date();
|
445
|
+
* hrs = Today.getUTCHours();
|
446
|
+
*
|
447
|
+
* @return {Number} Value between 0 and 23.
|
448
|
+
*/
|
449
|
+
|
450
|
+
/**
|
451
|
+
* @method getUTCMilliseconds
|
452
|
+
* Returns the numeric value corresponding to the current time.
|
453
|
+
*
|
454
|
+
* The following example assigns the milliseconds portion of the current time to the variable `ms`.
|
455
|
+
*
|
456
|
+
* var ms;
|
457
|
+
* Today = new Date();
|
458
|
+
* ms = Today.getUTCMilliseconds();
|
459
|
+
*
|
460
|
+
* @return {Number} Milliseconds portion of the Date.
|
461
|
+
*/
|
462
|
+
|
463
|
+
/**
|
464
|
+
* @method getUTCMinutes
|
465
|
+
* Returns the numeric value corresponding to the current time.
|
466
|
+
*
|
467
|
+
* The following example assigns the minutes portion of the current time to the variable `min`.
|
468
|
+
*
|
469
|
+
* var min;
|
470
|
+
* Today = new Date();
|
471
|
+
* min = Today.getUTCMinutes();
|
472
|
+
*
|
473
|
+
* @return {Number} Value between 0 and 59.
|
474
|
+
*/
|
475
|
+
|
476
|
+
/**
|
477
|
+
* @method getUTCMonth
|
478
|
+
* Returns the numeric value corresponding to the current time.
|
479
|
+
*
|
480
|
+
* The following example assigns the month portion of the current date to the variable `mon`.
|
481
|
+
*
|
482
|
+
* var mon;
|
483
|
+
* Today = new Date();
|
484
|
+
* mon = Today.getUTCMonth();
|
485
|
+
*
|
486
|
+
* @return {Number} Value between 0 (January) and 11 (December).
|
487
|
+
*/
|
488
|
+
|
489
|
+
/**
|
490
|
+
* @method getUTCSeconds
|
491
|
+
* Returns the numeric value corresponding to the current time.
|
492
|
+
*
|
493
|
+
* The following example assigns the seconds portion of the current time to the variable `sec`.
|
494
|
+
*
|
495
|
+
* var sec;
|
496
|
+
* Today = new Date();
|
497
|
+
* sec = Today.getUTCSeconds();
|
498
|
+
*
|
499
|
+
* @return {Number} Value between 0 and 59.
|
500
|
+
*/
|
501
|
+
|
502
|
+
/**
|
503
|
+
* @method setDate
|
504
|
+
* Sets the day of the month (1-31) for a specified date according to local time.
|
505
|
+
*
|
506
|
+
* If the parameter you specify is outside of the expected range, `setDate` attempts to update the
|
507
|
+
* date information in the `Date` object accordingly. For example, if you use 0 for `dayValue`, the
|
508
|
+
* date will be set to the last day of the previous month.
|
509
|
+
*
|
510
|
+
* The second statement below changes the day for theBigDay to July 24 from its original value.
|
511
|
+
*
|
512
|
+
* theBigDay = new Date("July 27, 1962 23:30:00")
|
513
|
+
* theBigDay.setDate(24)
|
514
|
+
*
|
515
|
+
* @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
|
516
|
+
* @return {Number} New date represented as milliseconds.
|
517
|
+
*/
|
518
|
+
|
519
|
+
/**
|
520
|
+
* @method setFullYear
|
521
|
+
* Sets the full year (4 digits for 4-digit years) for a specified date according to
|
522
|
+
* local time.
|
523
|
+
*
|
524
|
+
* If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the
|
525
|
+
* `getMonth` and `getDate` methods are used.
|
526
|
+
*
|
527
|
+
* If a parameter you specify is outside of the expected range, `setFullYear` attempts to update the
|
528
|
+
* other parameters and the date information in the `Date` object accordingly. For example, if you
|
529
|
+
* specify 15 for monthValue, the year is incremented by 1 (year + 1), and 3 is used for the month.
|
530
|
+
*
|
531
|
+
* theBigDay = new Date();
|
532
|
+
* theBigDay.setFullYear(1997);
|
533
|
+
*
|
534
|
+
* @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995.
|
535
|
+
* @param {Number} monthValue An integer between 0 and 11 representing the months January through
|
536
|
+
* December.
|
537
|
+
* @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you
|
538
|
+
* specify the `dayValue` parameter, you must also specify the `monthValue`.
|
539
|
+
* @return {Number} New date represented as milliseconds.
|
540
|
+
*/
|
541
|
+
|
542
|
+
/**
|
543
|
+
* @method setHours
|
544
|
+
* Sets the hours (0-23) for a specified date according to local time.
|
545
|
+
*
|
546
|
+
* If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values
|
547
|
+
* returned from the `getUTCMinutes`, `getUTCSeconds`, and `getMilliseconds` methods are used.
|
548
|
+
*
|
549
|
+
* If a parameter you specify is outside of the expected range, setHours attempts to update the date
|
550
|
+
* information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`, the
|
551
|
+
* minutes will be incremented by 1 (min + 1), and 40 will be used for seconds.
|
552
|
+
*
|
553
|
+
* theBigDay.setHours(7)
|
554
|
+
*
|
555
|
+
* @param {Number} hoursValue An integer between 0 and 23, representing the hour.
|
556
|
+
* @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
|
557
|
+
* @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the
|
558
|
+
* `secondsValue` parameter, you must also specify the `minutesValue`.
|
559
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the
|
560
|
+
* `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
|
561
|
+
* @return {Number} New date represented as milliseconds.
|
562
|
+
*/
|
563
|
+
|
564
|
+
/**
|
565
|
+
* @method setMilliseconds
|
566
|
+
* Sets the milliseconds (0-999) for a specified date according to local time.
|
567
|
+
*
|
568
|
+
* If you specify a number outside the expected range, the date information in the `Date` object is
|
569
|
+
* updated accordingly. For example, if you specify 1005, the number of seconds is incremented by 1,
|
570
|
+
* and 5 is used for the milliseconds.
|
571
|
+
*
|
572
|
+
* theBigDay = new Date();
|
573
|
+
* theBigDay.setMilliseconds(100);
|
574
|
+
*
|
575
|
+
* @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds.
|
576
|
+
* @return {Number} New date represented as milliseconds.
|
577
|
+
*/
|
578
|
+
|
579
|
+
/**
|
580
|
+
* @method setMinutes
|
581
|
+
* Sets the minutes (0-59) for a specified date according to local time.
|
582
|
+
*
|
583
|
+
* If you do not specify the `secondsValue` and `msValue` parameters, the values returned from
|
584
|
+
* `getSeconds` and `getMilliseconds` methods are used.
|
585
|
+
*
|
586
|
+
* If a parameter you specify is outside of the expected range, `setMinutes` attempts to update the
|
587
|
+
* date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
|
588
|
+
* the minutes (`minutesValue`) will be incremented by 1 (minutesValue + 1), and 40 will be used for
|
589
|
+
* seconds.
|
590
|
+
*
|
591
|
+
* theBigDay.setMinutes(45)
|
592
|
+
*
|
593
|
+
* @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
|
594
|
+
* @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you
|
595
|
+
* specify the secondsValue parameter, you must also specify the `minutesValue`.
|
596
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify
|
597
|
+
* the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
|
598
|
+
* @return {Number} New date represented as milliseconds.
|
599
|
+
*/
|
600
|
+
|
601
|
+
/**
|
602
|
+
* @method setMonth
|
603
|
+
* Sets the month (0-11) for a specified date according to local time.
|
604
|
+
*
|
605
|
+
* If you do not specify the `dayValue` parameter, the value returned from the `getDate` method is
|
606
|
+
* used.
|
607
|
+
*
|
608
|
+
* If a parameter you specify is outside of the expected range, `setMonth` attempts to update the date
|
609
|
+
* information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the year
|
610
|
+
* will be incremented by 1 (year + 1), and 3 will be used for month.
|
611
|
+
*
|
612
|
+
* theBigDay.setMonth(6)
|
613
|
+
*
|
614
|
+
* @param {Number} monthValue An integer between 0 and 11 (representing the months January through
|
615
|
+
* December).
|
616
|
+
* @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
|
617
|
+
* @return {Number} New date represented as milliseconds.
|
618
|
+
*/
|
619
|
+
|
620
|
+
/**
|
621
|
+
* @method setSeconds
|
622
|
+
* Sets the seconds (0-59) for a specified date according to local time.
|
623
|
+
*
|
624
|
+
* If you do not specify the `msValue` parameter, the value returned from the `getMilliseconds` method
|
625
|
+
* is used.
|
626
|
+
*
|
627
|
+
* If a parameter you specify is outside of the expected range, `setSeconds` attempts to update the
|
628
|
+
* date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
|
629
|
+
* the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds.
|
630
|
+
*
|
631
|
+
* theBigDay.setSeconds(30)
|
632
|
+
*
|
633
|
+
* @param {Number} secondsValue An integer between 0 and 59.
|
634
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify
|
635
|
+
* the`msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
|
636
|
+
* @return {Number} New date represented as milliseconds.
|
637
|
+
*/
|
638
|
+
|
639
|
+
/**
|
640
|
+
* @method setTime
|
641
|
+
* Sets the Date object to the time represented by a number of milliseconds since
|
642
|
+
* January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior.
|
643
|
+
*
|
644
|
+
* Use the `setTime` method to help assign a date and time to another `Date` object.
|
645
|
+
*
|
646
|
+
* theBigDay = new Date("July 1, 1999")
|
647
|
+
* sameAsBigDay = new Date()
|
648
|
+
* sameAsBigDay.setTime(theBigDay.getTime())
|
649
|
+
*
|
650
|
+
* @param {Number} timeValue An integer representing the number of milliseconds since 1 January
|
651
|
+
* 1970, 00:00:00 UTC.
|
652
|
+
* @return {Number} New date represented as milliseconds.
|
653
|
+
*/
|
654
|
+
|
655
|
+
/**
|
656
|
+
* @method setUTCDate
|
657
|
+
* Sets the day of the month (1-31) for a specified date according to universal time.
|
658
|
+
*
|
659
|
+
* If a parameter you specify is outside of the expected range, `setUTCDate` attempts to update the
|
660
|
+
* date information in the `Date` object accordingly. For example, if you use 40 for `dayValue`, and
|
661
|
+
* the month stored in the `Date` object is June, the day will be changed to 10 and the month will be
|
662
|
+
* incremented to July.
|
663
|
+
*
|
664
|
+
* theBigDay = new Date();
|
665
|
+
* theBigDay.setUTCDate(20);
|
666
|
+
*
|
667
|
+
* @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
|
668
|
+
* @return {Number} New date represented as milliseconds.
|
669
|
+
*/
|
670
|
+
|
671
|
+
/**
|
672
|
+
* @method setUTCFullYear
|
673
|
+
* Sets the full year (4 digits for 4-digit years) for a specified date according
|
674
|
+
* to universal time.
|
675
|
+
*
|
676
|
+
* If you do not specify the `monthValue` and `dayValue` parameters, the values returned from the
|
677
|
+
* `getMonth` and `getDate` methods are used.
|
678
|
+
*
|
679
|
+
* If a parameter you specify is outside of the expected range, `setUTCFullYear` attempts to update
|
680
|
+
* the other parameters and the date information in the `Date` object accordingly. For example, if you
|
681
|
+
* specify 15 for `monthValue`, the year is incremented by 1 (year + 1), and 3 is used for the month.
|
682
|
+
*
|
683
|
+
* theBigDay = new Date();
|
684
|
+
* theBigDay.setUTCFullYear(1997);
|
685
|
+
*
|
686
|
+
* @param {Number} yearValue An integer specifying the numeric value of the year, for example, 1995.
|
687
|
+
* @param {Number} monthValue An integer between 0 and 11 representing the months January through
|
688
|
+
* December.
|
689
|
+
* @param {Number} dayValue An integer between 1 and 31 representing the day of the month. If you
|
690
|
+
* specify the `dayValue` parameter, you must also specify the `monthValue`.
|
691
|
+
* @return {Number} New date represented as milliseconds.
|
692
|
+
*/
|
693
|
+
|
694
|
+
/**
|
695
|
+
* @method setUTCHours
|
696
|
+
* Sets the hour (0-23) for a specified date according to universal time.
|
697
|
+
*
|
698
|
+
* If you do not specify the `minutesValue`, `secondsValue`, and `msValue` parameters, the values
|
699
|
+
* returned from the `getUTCMinutes`, `getUTCSeconds`, and `getUTCMilliseconds` methods are used.
|
700
|
+
*
|
701
|
+
* If a parameter you specify is outside of the expected range, `setUTCHours` attempts to update the
|
702
|
+
* date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
|
703
|
+
* the minutes will be incremented by 1 (min + 1), and 40 will be used for seconds.
|
704
|
+
*
|
705
|
+
* theBigDay = new Date();
|
706
|
+
* theBigDay.setUTCHours(8);
|
707
|
+
*
|
708
|
+
* @param {Number} hoursValue An integer between 0 and 23, representing the hour.
|
709
|
+
* @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
|
710
|
+
* @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the
|
711
|
+
* `secondsValue` parameter, you must also specify the `minutesValue`.
|
712
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the
|
713
|
+
* `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
|
714
|
+
* @return {Number} New date represented as milliseconds.
|
715
|
+
*/
|
716
|
+
|
717
|
+
/**
|
718
|
+
* @method setUTCMilliseconds
|
719
|
+
* Sets the milliseconds (0-999) for a specified date according to universal time.
|
720
|
+
*
|
721
|
+
* If a parameter you specify is outside of the expected range, `setUTCMilliseconds` attempts to
|
722
|
+
* update the date information in the `Date` object accordingly. For example, if you use 1100 for
|
723
|
+
* `millisecondsValue`, the seconds stored in the Date object will be incremented by 1, and 100 will
|
724
|
+
* be used for milliseconds.
|
725
|
+
*
|
726
|
+
* theBigDay = new Date();
|
727
|
+
* theBigDay.setUTCMilliseconds(500);
|
728
|
+
*
|
729
|
+
* @param {Number} millisecondsValue A number between 0 and 999, representing the milliseconds.
|
730
|
+
* @return {Number} New date represented as milliseconds.
|
731
|
+
*/
|
732
|
+
|
733
|
+
/**
|
734
|
+
* @method setUTCMinutes
|
735
|
+
* Sets the minutes (0-59) for a specified date according to universal time.
|
736
|
+
*
|
737
|
+
* If you do not specify the `secondsValue` and `msValue` parameters, the values returned from
|
738
|
+
* `getUTCSeconds` and `getUTCMilliseconds` methods are used.
|
739
|
+
*
|
740
|
+
* If a parameter you specify is outside of the expected range, `setUTCMinutes` attempts to update the
|
741
|
+
* date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
|
742
|
+
* the minutes (`minutesValue`) will be incremented by 1 (`minutesValue` + 1), and 40 will be used for
|
743
|
+
* seconds.
|
744
|
+
*
|
745
|
+
* theBigDay = new Date();
|
746
|
+
* theBigDay.setUTCMinutes(43);
|
747
|
+
*
|
748
|
+
* @param {Number} minutesValue An integer between 0 and 59, representing the minutes.
|
749
|
+
* @param {Number} secondsValue An integer between 0 and 59, representing the seconds. If you specify the `secondsValue` parameter, you must also specify the `minutesValue`.
|
750
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds. If you specify the `msValue` parameter, you must also specify the `minutesValue` and `secondsValue`.
|
751
|
+
* @return {Number} New date represented as milliseconds.
|
752
|
+
*/
|
753
|
+
|
754
|
+
/**
|
755
|
+
* @method setUTCMonth
|
756
|
+
* Sets the month (0-11) for a specified date according to universal time.
|
757
|
+
*
|
758
|
+
* If you do not specify the `dayValue` parameter, the value returned from the `getUTCDate` method is
|
759
|
+
* used.
|
760
|
+
*
|
761
|
+
* If a parameter you specify is outside of the expected range, `setUTCMonth` attempts to update the
|
762
|
+
* date information in the `Date` object accordingly. For example, if you use 15 for `monthValue`, the
|
763
|
+
* year will be incremented by 1 (year + 1), and 3 will be used for month.
|
764
|
+
*
|
765
|
+
* theBigDay = new Date();
|
766
|
+
* theBigDay.setUTCMonth(11);
|
767
|
+
*
|
768
|
+
* @param {Number} monthValue An integer between 0 and 11, representing the months January through
|
769
|
+
* December.
|
770
|
+
* @param {Number} dayValue An integer from 1 to 31, representing the day of the month.
|
771
|
+
* @return {Number} New date represented as milliseconds.
|
772
|
+
*/
|
773
|
+
|
774
|
+
/**
|
775
|
+
* @method setUTCSeconds
|
776
|
+
* Sets the seconds (0-59) for a specified date according to universal time.
|
777
|
+
*
|
778
|
+
* If you do not specify the `msValue` parameter, the value returned from the `getUTCMilliseconds`
|
779
|
+
* methods is used.
|
780
|
+
*
|
781
|
+
* If a parameter you specify is outside of the expected range, `setUTCSeconds` attempts to update the
|
782
|
+
* date information in the `Date` object accordingly. For example, if you use 100 for `secondsValue`,
|
783
|
+
* the minutes stored in the `Date` object will be incremented by 1, and 40 will be used for seconds.
|
784
|
+
*
|
785
|
+
* theBigDay = new Date();
|
786
|
+
* theBigDay.setUTCSeconds(20);
|
787
|
+
*
|
788
|
+
* @param {Number} secondsValue An integer between 0 and 59.
|
789
|
+
* @param {Number} msValue A number between 0 and 999, representing the milliseconds.
|
790
|
+
* @return {Number} New date represented as milliseconds.
|
791
|
+
*/
|
792
|
+
|
793
|
+
/**
|
794
|
+
* @method toDateString
|
795
|
+
* Returns the "date" portion of the Date as a human-readable string in American English.
|
796
|
+
*
|
797
|
+
* {@link Date} instances refer to a specific point in time. Calling `toString` will return the
|
798
|
+
* date formatted in a human readable form in American English. In SpiderMonkey, this consists of the
|
799
|
+
* date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and time
|
800
|
+
* zone). Sometimes it is desirable to obtain a string of the date portion; such a thing can be
|
801
|
+
* accomplished with the `toDateString` method.
|
802
|
+
*
|
803
|
+
* The `toDateString` method is especially useful because compliant engines implementing ECMA-262 may
|
804
|
+
* differ in the string obtained from `toString` for `Date` objects, as the format is implementation-
|
805
|
+
* dependent and simple string slicing approaches may not produce consistent results across multiple
|
806
|
+
* engines.
|
807
|
+
*
|
808
|
+
* var d = new Date(1993, 6, 28, 14, 39, 7);
|
809
|
+
* println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
|
810
|
+
* println(d.toDateString()); // prints Wed Jul 28 1993
|
811
|
+
*
|
812
|
+
* @return {String} Human-readable string, in local time.
|
813
|
+
*/
|
814
|
+
|
815
|
+
/**
|
816
|
+
* @method toLocaleDateString
|
817
|
+
* Returns the "date" portion of the Date as a string, using the current locale's
|
818
|
+
* conventions.
|
819
|
+
*
|
820
|
+
* The `toLocaleDateString` method relies on the underlying operating system in formatting dates. It
|
821
|
+
* converts the date to a string using the formatting convention of the operating system where the
|
822
|
+
* script is running. For example, in the United States, the month appears before the date (04/15/98),
|
823
|
+
* whereas in Germany the date appears before the month (15.04.98). If the operating system is not
|
824
|
+
* year-2000 compliant and does not use the full year for years before 1900 or over 2000,
|
825
|
+
* `toLocaleDateString` returns a string that is not year-2000 compliant. `toLocaleDateString` behaves
|
826
|
+
* similarly to `toString` when converting a year that the operating system does not properly format.
|
827
|
+
*
|
828
|
+
* Methods such as `getDate`, `getMonth`, and `getFullYear` give more portable results than
|
829
|
+
* `toLocaleDateString`. Use `toLocaleDateString` when the intent is to display to the user a string
|
830
|
+
* formatted using the regional format chosen by the user. Be aware that this method, due to its
|
831
|
+
* nature, behaves differently depending on the operating system and on the user's settings.
|
832
|
+
*
|
833
|
+
* In the following example, `today` is a `Date` object:
|
834
|
+
*
|
835
|
+
* today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11
|
836
|
+
* today.toLocaleDateString()
|
837
|
+
*
|
838
|
+
* In this example, `toLocaleDateString` returns a string value that is similar to the following form.
|
839
|
+
* The exact format depends on the platform, locale and user's settings.
|
840
|
+
*
|
841
|
+
* 12/18/95
|
842
|
+
*
|
843
|
+
* You shouldn't use this method in contexts where you rely on a particular format or locale.
|
844
|
+
*
|
845
|
+
* "Last visit: " + someDate.toLocaleDateString(); // Good example
|
846
|
+
* "Last visit was at " + someDate.toLocaleDateString(); // Bad example
|
847
|
+
*
|
848
|
+
* @return {String} Human-readable string that may be formatted differently depending
|
849
|
+
* on the country.
|
850
|
+
*/
|
851
|
+
|
852
|
+
/**
|
853
|
+
* @method toLocaleString
|
854
|
+
* Converts a date to a string, using the current locale's conventions. Overrides
|
855
|
+
* the `Object.toLocaleString` method.
|
856
|
+
*
|
857
|
+
* The `toLocaleString` method relies on the underlying operating system in formatting dates. It
|
858
|
+
* converts the date to a string using the formatting convention of the operating system where the
|
859
|
+
* script is running. For example, in the United States, the month appears before the date (04/15/98),
|
860
|
+
* whereas in Germany the date appears before the month (15.04.98). If the operating system is not
|
861
|
+
* year-2000 compliant and does not use the full year for years before 1900 or over 2000,
|
862
|
+
* `toLocaleString` returns a string that is not year-2000 compliant. `toLocaleString` behaves
|
863
|
+
* similarly to `toString` when converting a year that the operating system does not properly format.
|
864
|
+
*
|
865
|
+
* Methods such as `getDate`, `getMonth`, `getFullYear`, `getHours`, `getMinutes`, and `getSeconds`
|
866
|
+
* give more portable results than `toLocaleString`. Use `toLocaleString` when the intent is to
|
867
|
+
* display to the user a string formatted using the regional format chosen by the user. Be aware that
|
868
|
+
* this method, due to its nature, behaves differently depending on the operating system and on the
|
869
|
+
* user's settings.
|
870
|
+
*
|
871
|
+
* In the following example, `today` is a `Date` object:
|
872
|
+
*
|
873
|
+
* today = new Date(95,11,18,17,28,35); //months are represented by 0 to 11
|
874
|
+
* today.toLocaleString();
|
875
|
+
*
|
876
|
+
* In this example, `toLocaleString` returns a string value that is similar to the following form. The
|
877
|
+
* exact format depends on the platform, locale and user's settings.
|
878
|
+
*
|
879
|
+
* 12/18/95 17:28:35
|
880
|
+
*
|
881
|
+
* You shouldn't use this method in contexts where you rely on a particular format or locale.
|
882
|
+
*
|
883
|
+
* "Last visit: " + someDate.toLocaleString(); // Good example
|
884
|
+
* "Last visit was at " + someDate.toLocaleString(); // Bad example
|
885
|
+
*
|
886
|
+
* @return {String} Human-readable string that may be formatted differently depending
|
887
|
+
* on the country.
|
888
|
+
*/
|
889
|
+
|
890
|
+
/**
|
891
|
+
* @method toLocaleTimeString
|
892
|
+
* Returns the "time" portion of the Date as a string, using the current locale's
|
893
|
+
* conventions.
|
894
|
+
*
|
895
|
+
* The `toLocaleTimeString` method relies on the underlying operating system in formatting dates. It
|
896
|
+
* converts the date to a string using the formatting convention of the operating system where the
|
897
|
+
* script is running. For example, in the United States, the month appears before the date (04/15/98),
|
898
|
+
* whereas in Germany the date appears before the month (15.04.98).
|
899
|
+
*
|
900
|
+
* Methods such as `getHours`, `getMinutes`, and `getSeconds` give more consistent results than
|
901
|
+
* `toLocaleTimeString`. Use `toLocaleTimeString` when the intent is to display to the user a string
|
902
|
+
* formatted using the regional format chosen by the user. Be aware that this method, due to its
|
903
|
+
* nature, behaves differently depending on the operating system and on the user's settings.
|
904
|
+
*
|
905
|
+
* In the following example, `today` is a `Date` object:
|
906
|
+
*
|
907
|
+
* today = new Date(95,11,18,17,28,35) //months are represented by 0 to 11
|
908
|
+
* today.toLocaleTimeString()
|
909
|
+
*
|
910
|
+
* In this example, `toLocaleTimeString` returns a string value that is similar to the following form.
|
911
|
+
* The exact format depends on the platform.
|
912
|
+
*
|
913
|
+
* 17:28:35
|
914
|
+
*
|
915
|
+
* You shouldn't use this method in contexts where you rely on a particular format or locale.
|
916
|
+
*
|
917
|
+
* "Last visit: " + someDate.toLocaleTimeString(); // Good example
|
918
|
+
* "Last visit was at " + someDate.toLocaleTimeString(); // Bad example
|
919
|
+
*
|
920
|
+
* @return {String} Human-readable string that may be formatted differently depending
|
921
|
+
* on the country.
|
922
|
+
*/
|
923
|
+
|
924
|
+
/**
|
925
|
+
* @method toString
|
926
|
+
* Returns a string representing the specified Date object. Overrides the
|
927
|
+
* `Object.prototype.toString` method.
|
928
|
+
*
|
929
|
+
* The `Date` object overrides the toString method of the Object object; it does not inherit
|
930
|
+
* `Object.toString`. For `Date` objects, the `toString` method returns a string representation of the
|
931
|
+
* object.
|
932
|
+
*
|
933
|
+
* `toString` always returns a string representation of the date in American English.
|
934
|
+
*
|
935
|
+
* JavaScript calls the `toString` method automatically when a date is to be represented as a text
|
936
|
+
* value or when a date is referred to in a string concatenation.
|
937
|
+
*
|
938
|
+
* The following assigns the `toString` value of a `Date` object to `myVar`:
|
939
|
+
*
|
940
|
+
* x = new Date();
|
941
|
+
* myVar=x.toString(); //assigns a value to myVar similar to:
|
942
|
+
* //Mon Sep 28 1998 14:36:22 GMT-0700 (Pacific Daylight Time)
|
943
|
+
*
|
944
|
+
* @return {String} Human-readable string of the date in local time.
|
945
|
+
*/
|
946
|
+
|
947
|
+
/**
|
948
|
+
* @method toTimeString
|
949
|
+
* Returns the "time" portion of the Date as a human-readable string.
|
950
|
+
*
|
951
|
+
* {@link Date} instances refer to a specific point in time. Calling `toString` will return the
|
952
|
+
* date formatted in a human readable form in American English. In SpiderMonkey, this consists of the
|
953
|
+
* date portion (day, month, and year) followed by the time portion (hours, minutes, seconds, and
|
954
|
+
* time zone). Sometimes it is desirable to obtain a string of the time portion; such a thing can be
|
955
|
+
* accomplished with the `toTimeString` method.
|
956
|
+
*
|
957
|
+
* The `toTimeString` method is especially useful because compliant engines implementing ECMA-262 may
|
958
|
+
* differ in the string obtained from `toString` for `Date` objects, as the format is implementation-
|
959
|
+
* dependent; simple string slicing approaches may not produce consistent results across multiple
|
960
|
+
* engines.
|
961
|
+
*
|
962
|
+
* var d = new Date(1993, 6, 28, 14, 39, 7);
|
963
|
+
* println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
|
964
|
+
* println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT)
|
965
|
+
*
|
966
|
+
* @return {String} Human-readable string of the date in local time.
|
967
|
+
*/
|
968
|
+
|
969
|
+
/**
|
970
|
+
* @method toUTCString
|
971
|
+
* Converts a date to a string, using the universal time convention.
|
972
|
+
*
|
973
|
+
* The value returned by `toUTCString` is a readable string in American English in the UTC time zone.
|
974
|
+
* The format of the return value may vary according to the platform.
|
975
|
+
*
|
976
|
+
* var today = new Date();
|
977
|
+
* var UTCstring = today.toUTCString();
|
978
|
+
* // Mon, 03 Jul 2006 21:44:38 GMT
|
979
|
+
*
|
980
|
+
* @return {String} String of the date in UTC.
|
981
|
+
*/
|
982
|
+
|
983
|
+
/**
|
984
|
+
* @method valueOf
|
985
|
+
* Returns the primitive value of a Date object. Overrides the
|
986
|
+
* Object.prototype.valueOf method.
|
987
|
+
*
|
988
|
+
* The `valueOf` method returns the primitive value of a `Date` object as a number data type, the
|
989
|
+
* number of milliseconds since midnight 01 January, 1970 UTC.
|
990
|
+
*
|
991
|
+
* This method is functionally equivalent to the `getTime` method.
|
992
|
+
*
|
993
|
+
* This method is usually called internally by JavaScript and not explicitly in code.
|
994
|
+
*
|
995
|
+
* x = new Date(56, 6, 17);
|
996
|
+
* myVar = x.valueOf(); //assigns -424713600000 to myVar
|
997
|
+
*
|
998
|
+
* @return {Number} Date represented as milliseconds.
|
999
|
+
*/
|