Date.html 43 KB

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