Kaydet (Commit) ab2d34ba authored tarafından akoskaaa's avatar akoskaaa Kaydeden (comit) Tim Graham

Fixed #25856 -- Added %B support to Date.strftime.

This enables the admin to display the correct localized month name if %B
is used in the date format.
üst a6074e89
...@@ -204,4 +204,5 @@ depends on core.js for utility functions like removeChildren or quickElement ...@@ -204,4 +204,5 @@ depends on core.js for utility functions like removeChildren or quickElement
} }
}; };
window.Calendar = Calendar; window.Calendar = Calendar;
window.CalendarNamespace = CalendarNamespace;
})(); })();
...@@ -153,8 +153,15 @@ function findPosY(obj) { ...@@ -153,8 +153,15 @@ function findPosY(obj) {
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond(); return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
}; };
Date.prototype.getFullMonthName = function() {
return typeof window.CalendarNamespace === "undefined"
? this.getTwoDigitMonth()
: window.CalendarNamespace.monthsOfYear[this.getMonth()];
};
Date.prototype.strftime = function(format) { Date.prototype.strftime = function(format) {
var fields = { var fields = {
B: this.getFullMonthName(),
c: this.toString(), c: this.toString(),
d: this.getTwoDigitDate(), d: this.getTwoDigitDate(),
H: this.getTwoDigitHour(), H: this.getTwoDigitHour(),
......
...@@ -54,6 +54,7 @@ test('Date.getHourMinuteSecond', function(assert) { ...@@ -54,6 +54,7 @@ test('Date.getHourMinuteSecond', function(assert) {
test('Date.strftime', function(assert) { test('Date.strftime', function(assert) {
var date = new Date(2014, 6, 1, 11, 0, 5); var date = new Date(2014, 6, 1, 11, 0, 5);
assert.equal(date.strftime('%Y-%m-%d %H:%M:%S'), '2014-07-01 11:00:05'); assert.equal(date.strftime('%Y-%m-%d %H:%M:%S'), '2014-07-01 11:00:05');
assert.equal(date.strftime('%B %d, %Y'), 'July 01, 2014');
}); });
test('String.strptime', function(assert) { test('String.strptime', function(assert) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment