UNPKG

elmer-ui-core

Version:

web app framework

33 lines (32 loc) 1.17 kB
if (!String.prototype["__defineGetter__"]) { String.prototype["__defineGetter__"] = function (color, func) { this[color] = func; }; } if (!Date.prototype.format) { Date.prototype.format = function (formatStr) { var year = this.getFullYear(); var month = this.getMonth() + 1; var date = this.getDate(); var hour = this.getHours(); var minutes = this.getMinutes(); var second = this.getSeconds(); var milliseconds = this.getMilliseconds(); month = month > 9 ? month : "0" + month; date = date > 9 ? date : "0" + date; hour = hour > 9 ? hour : "0" + hour; minutes = minutes > 9 ? minutes : "0" + minutes; second = second > 9 ? second : "0" + second; var result = formatStr.replace(/YYYY/g, year) .replace(/MM/g, month) .replace(/DD/g, date) .replace(/H/ig, hour) .replace(/i/g, minutes) .replace(/ms/g, milliseconds) .replace(/s/g, second) .replace(/yyyy/g, year) .replace(/mm/g, month) .replace(/dd/g, date); return result; }; }