1
0

format.js 736 B

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