format.js 755 B

1234567891011121314151617181920
  1. /* eslint id-length: "off" */
  2. "use strict";
  3. var pad = require("../../number/#/pad")
  4. , date = require("../valid-date")
  5. , format;
  6. format = require("../../string/format-method")({
  7. Y: function () { return String(this.getFullYear()); },
  8. y: function () { return String(this.getFullYear()).slice(-2); },
  9. m: function () { return pad.call(this.getMonth() + 1, 2); },
  10. d: function () { return pad.call(this.getDate(), 2); },
  11. H: function () { return pad.call(this.getHours(), 2); },
  12. M: function () { return pad.call(this.getMinutes(), 2); },
  13. S: function () { return pad.call(this.getSeconds(), 2); },
  14. L: function () { return pad.call(this.getMilliseconds(), 3); }
  15. });
  16. module.exports = function (pattern) { return format.call(date(this), pattern); };