Respect locale in time format of attendees window

pull/17/head
Francis Lachapelle 2013-12-18 22:16:28 -05:00
parent 7369a82bab
commit 1f7994d1bf
4 changed files with 28 additions and 7 deletions

1
NEWS
View File

@ -12,6 +12,7 @@ Enhancements
using CIDs. This prevents Outlook issues.
- updated Finnish translation
- XMLHttpRequest.js is now loaded conditionaly (< IE9)
- format time in attendees invitation window according to the user's locale
Bug fixes
-

View File

@ -18,6 +18,7 @@
<script type="text/javascript">
var dayStartHour = <var:string value="dayStartHour"/>;
var dayEndHour = <var:string value="dayEndHour"/>;
var timeFormat = '<var:string value="userDefaults.timeFormat" const:escapeHTML="NO"/>';
</script>
<div id="attendeesView">
<form const:href=""

View File

@ -14,6 +14,31 @@ String.prototype.formatted = function() {
return newString;
};
String.prototype.formatTime = function(hours, minutes) {
var newString = this;
// See http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSCalendarDate.html#method$NSCalendarDate-descriptionWithCalendarFormat$
var p = 'am', i = hours, m = minutes;
if (hours > 12) {
p = 'pm';
i = hours % 12;
}
if (minutes < 10) {
m = '0' + minutes;
}
// %H : hour as a decimal number using 24-hour clock
newString = newString.replace("%H", hours < 10 ? '0' + hours : hours);
// %I : hour as a decimal number using 12-hour clock
newString = newString.replace("%I", i < 10 ? '0' + i : i);
// %M : minute as decimal number
newString = newString.replace("%M", m);
// %p : 'am' or 'pm'
newString = newString.replace("%p", p);
return newString;
};
String.prototype.repeat = function(count) {
var newString = "";
for (var i = 0; i < count; i++) {

View File

@ -1453,14 +1453,8 @@ function prepareTableHeaders() {
rows[0].appendChild(header1b);
for (var hour = displayStartHour; hour < (displayEndHour + 1); hour++) {
var header2 = document.createElement("th");
var text = hour + ":00";
if (hour < 10)
text = "0" + text;
if (hour >= dayStartHour && hour < dayEndHour)
$(header2).addClassName ("officeHour");
header2.appendChild(document.createTextNode(text));
header2.appendChild(document.createTextNode(timeFormat.formatTime(hour, 0)));
rows[1].appendChild(header2);
var header3 = document.createElement("th");
for (var span = 0; span < 4; span++) {
var spanElement = document.createElement("span");