diff -r b758351d191f -r cc9b7e14412b web/lib/django/contrib/admin/media/js/core.js --- a/web/lib/django/contrib/admin/media/js/core.js Wed May 19 17:43:59 2010 +0200 +++ b/web/lib/django/contrib/admin/media/js/core.js Tue May 25 02:43:45 2010 +0200 @@ -115,6 +115,10 @@ return (y < 38) ? y + 2000 : y + 1900; } +Date.prototype.getTwelveHours = function() { + return (this.getHours() <= 12) ? this.getHours() : 24 - this.getHours(); +} + Date.prototype.getTwoDigitMonth = function() { return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1); } @@ -123,6 +127,10 @@ return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate(); } +Date.prototype.getTwoDigitTwelveHour = function() { + return (this.getTwelveHours() < 10) ? '0' + this.getTwelveHours() : this.getTwelveHours(); +} + Date.prototype.getTwoDigitHour = function() { return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours(); } @@ -147,6 +155,37 @@ return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond(); } +Date.prototype.strftime = function(format) { + var fields = { + c: this.toString(), + d: this.getTwoDigitDate(), + H: this.getTwoDigitHour(), + I: this.getTwoDigitTwelveHour(), + m: this.getTwoDigitMonth(), + M: this.getTwoDigitMinute(), + p: (this.getHours() >= 12) ? 'PM' : 'AM', + S: this.getTwoDigitSecond(), + w: '0' + this.getDay(), + x: this.toLocaleDateString(), + X: this.toLocaleTimeString(), + y: ('' + this.getFullYear()).substr(2, 4), + Y: '' + this.getFullYear(), + '%' : '%' + }; + var result = '', i = 0; + while (i < format.length) { + if (format.charAt(i) === '%') { + result = result + fields[format.charAt(i + 1)]; + ++i; + } + else { + result = result + format.charAt(i); + } + ++i; + } + return result; +} + // ---------------------------------------------------------------------------- // String object extensions // ----------------------------------------------------------------------------