123456789101112131415161718192021222324252627282930313233343536373839
  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 () {
  8. return String(this.getFullYear());
  9. },
  10. y: function () {
  11. return String(this.getFullYear()).slice(-2);
  12. },
  13. m: function () {
  14. return pad.call(this.getMonth() + 1, 2);
  15. },
  16. d: function () {
  17. return pad.call(this.getDate(), 2);
  18. },
  19. H: function () {
  20. return pad.call(this.getHours(), 2);
  21. },
  22. M: function () {
  23. return pad.call(this.getMinutes(), 2);
  24. },
  25. S: function () {
  26. return pad.call(this.getSeconds(), 2);
  27. },
  28. L: function () {
  29. return pad.call(this.getMilliseconds(), 3);
  30. }
  31. });
  32. module.exports = function (pattern) {
  33. return format.call(date(this), pattern);
  34. };