// Automatically compiled to JavaScript var __hasProp = Object.prototype.hasOwnProperty; Number.prototype.pad = function(digits, signed) { var s; s = Math.abs(this).toString(); while (s.length < digits) { s = "0" + s; } return (this < 0 ? "-" : (signed ? "+" : "")) + s; }; Date.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; Date.weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; Date.formats = { "a": function() { return Date.weekdays[this.getDay()].substring(0, 3); }, "A": function() { return Date.weekdays[this.getDay()]; }, "b": function() { return Date.months[this.getMonth()].substring(0, 3); }, "B": function() { return Date.months[this.getMonth()]; }, "c": function() { return this.toLocaleString(); }, "d": function() { return this.getDate().toString(); }, "F": function() { return "" + (this.getFullYear()) + "-" + (this.getMonth() + 1) + "-" + (this.getDate()); }, "H": function() { return this.getHours().pad(2); }, "I": function() { return "" + ((this.getHours() % 12) || 12); }, "j": function() { return this.getDayOfYear(); }, "L": function() { return this.getMilliseconds().pad(3); }, "m": function() { return (this.getMonth() + 1).pad(2); }, "M": function() { return this.getMinutes().pad(2); }, "N": function() { return this.getMilliseconds().pad(3); }, "p": function() { if (this.getHours() < 12) { return "AM"; } else { return "PM"; } }, "P": function() { if (this.getHours() < 12) { return "am"; } else { return "pm"; } }, "S": function() { return this.getSeconds().pad(2); }, "s": function() { return Math.floor(this.getTime() / 1000); }, "U": function() { return this.getWeekOfYear(); }, "w": function() { return this.getDay(); }, "W": function() { return this.getWeekOfYear(1); }, "y": function() { return this.getFullYear() % 100; }, "Y": function() { return this.getFullYear(); }, "x": function() { return this.toLocaleDateString(); }, "X": function() { return this.toLocaleTimeString(); }, "z": function() { var z; return Math.floor((z = -this.getTimezoneOffset()) / 60).pad(2, true) + (Math.abs(z) % 60).pad(2); }, "Z": function() { return /\(([^\)]*)\)$/.exec(this.toString())[1]; } }; Date.prototype.format = function(fmt) { var callback, char, part, parts, r, _ref; parts = (fmt || "%c").split("%%"); _ref = Date.formats; for (char in _ref) { if (!__hasProp.call(_ref, char)) continue; callback = _ref[char]; r = new RegExp("%" + char, "g"); parts = (function() { var _i, _len, _results, _this = this; _results = []; for (_i = 0, _len = parts.length; _i < _len; _i++) { part = parts[_i]; _results.push(part.replace(r, function() { return callback.apply(_this); })); } return _results; }).call(this); } return parts.join("%"); }; Date.prototype.getDayOfYear = function() { return Math.ceil((this.getTime() - new Date(this.getFullYear(), 0, 1).getTime()) / 24 / 60 / 60 / 1000); }; Date.prototype.getWeekOfYear = function(start) { if (start == null) start = 0; return Math.floor((this.getDayOfYear() - (start + 7 - new Date(this.getFullYear(), 0, 1).getDay()) % 7) / 7) + 1; };