polyfill_Date.js.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: polyfill/Date.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: polyfill/Date.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>// Licensed Materials - Property of IBM
  20. //
  21. // IBM Watson Analytics
  22. //
  23. // (C) Copyright IBM Corp. 2015
  24. //
  25. // US Government Users Restricted Rights - Use, duplication or
  26. // disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  27. ( function( Date, ObjectPolyfill )
  28. {
  29. "use strict";
  30. /**
  31. * Polyfills for {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date}.
  32. * @class module:barejs/polyfill.Date
  33. */
  34. /** @lends module:barejs/polyfill.Date */
  35. var stat = {};
  36. /** @lends module:barejs/polyfill.Date# */
  37. var proto = {};
  38. /*istanbul ignore else: We test with __ES__ set to 3*/
  39. if ( __ES__ &lt; 5 )
  40. {
  41. /**
  42. * The Date.now() method returns the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
  43. * @returns {number} The number of milliseconds.
  44. */
  45. stat.now = function now()
  46. {
  47. return new Date().getTime();
  48. };
  49. ( function()
  50. {
  51. /**
  52. * Ensure the number is _length characters wide.
  53. * @param {number} _value The number to pad.
  54. * @param {number} _length The length to pad to. Note: values > 4 are not supported
  55. * @returns {string} The number, optionally padded with leading zeros
  56. */
  57. function padZero( _value, _length )
  58. {
  59. var nr = String( _value );
  60. if ( nr.length &lt; _length )
  61. nr = "0000".substr( 0, _length - nr.length ) + nr;
  62. return nr;
  63. }
  64. /**
  65. * The toISOString() method returns a string in simplified extended ISO format (ISO 8601), which
  66. * is always 24 characters long: YYYY-MM-DDTHH:mm:ss.sssZ. The timezone is always zero UTC
  67. * offset, as denoted by the suffix "Z".
  68. * @returns {string} The date formatted as (zero UTC) ISO 8601.
  69. */
  70. proto.toISOString = function toISOString()
  71. {
  72. // jshint validthis:true
  73. return padZero( this.getUTCFullYear(), 4 ) +
  74. "-" + padZero( this.getUTCMonth() + 1, 2 ) +
  75. "-" + padZero( this.getUTCDate(), 2 ) +
  76. "T" + padZero( this.getUTCHours(), 2 ) +
  77. ":" + padZero( this.getUTCMinutes(), 2 ) +
  78. ":" + padZero( this.getUTCSeconds(), 2 ) +
  79. "." + ( this.getUTCMilliseconds() / 1000 ).toFixed( 3 ).slice( 2, 5 ) +
  80. "Z";
  81. };
  82. }() );
  83. // End of ES5 polyfill scope
  84. }
  85. ObjectPolyfill.polyfill( Date, stat, proto, exports, "Date" );
  86. // End of module
  87. }( Date, require( "./Object" ) ) );
  88. </code></pre>
  89. </article>
  90. </section>
  91. </div>
  92. <nav>
  93. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-barejs.html">barejs</a></li><li><a href="module-barejs_polyfill.html">barejs/polyfill</a></li><li><a href="module-barejs_polyfill_Intl.html">barejs/polyfill/Intl</a></li></ul><h3>Classes</h3><ul><li><a href="module-barejs.decl.html">decl</a></li><li><a href="module-barejs.decl-Enum.html">Enum</a></li><li><a href="module-barejs.decl-Interface.html">Interface</a></li><li><a href="module-barejs.decl-SpecialType.html">SpecialType</a></li><li><a href="module-barejs.Destroyable.html">Destroyable</a></li><li><a href="module-barejs.EventArgs.html">EventArgs</a></li><li><a href="module-barejs.Evented.html">Evented</a></li><li><a href="module-barejs.Evented-EventedHandle.html">EventedHandle</a></li><li><a href="module-barejs.Exception.html">Exception</a></li><li><a href="module-barejs_polyfill.Array.html">Array</a></li><li><a href="module-barejs_polyfill.Date.html">Date</a></li><li><a href="module-barejs_polyfill.EntryStore.html">EntryStore</a></li><li><a href="module-barejs_polyfill.EntryStore.Iterator.html">Iterator</a></li><li><a href="module-barejs_polyfill.Function.html">Function</a></li><li><a href="module-barejs_polyfill.Map.html">Map</a></li><li><a href="module-barejs_polyfill.Map-MapIterator.html">MapIterator</a></li><li><a href="module-barejs_polyfill.Math.html">Math</a></li><li><a href="module-barejs_polyfill.Number.html">Number</a></li><li><a href="module-barejs_polyfill.Object.html">Object</a></li><li><a href="module-barejs_polyfill.Promise.html">Promise</a></li><li><a href="module-barejs_polyfill.Set.html">Set</a></li><li><a href="module-barejs_polyfill.Set-SetIterator.html">SetIterator</a></li><li><a href="module-barejs_polyfill.String.html">String</a></li><li><a href="module-barejs_polyfill.Symbol.html">Symbol</a></li><li><a href="module-barejs_polyfill.WeakMap.html">WeakMap</a></li><li><a href="module-barejs_polyfill.WeakSet.html">WeakSet</a></li><li><a href="module-barejs_polyfill_Intl.DateTimeFormat.html">DateTimeFormat</a></li><li><a href="module-barejs_polyfill_Intl.DateTimeFormat-DateTimeFormatOptions.html">DateTimeFormatOptions</a></li><li><a href="module-barejs_polyfill_Intl.NumberFormat.html">NumberFormat</a></li><li><a href="module-barejs_polyfill_Intl.NumberFormat-NumberFormatOptions.html">NumberFormatOptions</a></li><li><a href="module-barejs_polyfill_Intl-Format.html">Format</a></li></ul>
  94. </nav>
  95. <br class="clear">
  96. <footer>
  97. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Oct 03 2018 15:59:33 GMT+0200 (W. Europe Daylight Time)
  98. </footer>
  99. <script> prettyPrint(); </script>
  100. <script src="scripts/linenumber.js"> </script>
  101. </body>
  102. </html>