(js) Add support for %p in date formatting

Fixes #3480
This commit is contained in:
Francis Lachapelle
2016-02-01 20:54:37 -05:00
parent a95fd25e09
commit 6bfc44fb53
4 changed files with 21 additions and 3 deletions
+5
View File
@@ -232,6 +232,11 @@
// Add strings from Locale
NSDictionary *moreStrings;
// AM/PM
moreStrings = [NSDictionary dictionaryWithObjects: [locale objectForKey: NSAMPMDesignation]
forKeys: [UIxComponent amPmLabelKeys]];
[strings addEntriesFromDictionary: moreStrings];
// Month names
moreStrings = [NSDictionary dictionaryWithObjects: [locale objectForKey: NSMonthNameArray]
forKeys: [UIxComponent monthLabelKeys]];
+5 -3
View File
@@ -1,14 +1,15 @@
/*
Copyright (C) 2000-2005 SKYRIX Software AG
Copyright (C) 2007-2016 Inverse inc.
This file is part of OpenGroupware.org.
This file is part of SOGo
OGo is free software; you can redistribute it and/or modify it under
SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
@@ -46,6 +47,7 @@
NSArray *languages;
}
+ (NSArray *) amPmLabelKeys;
+ (NSArray *) monthLabelKeys;
+ (NSArray *) abbrMonthLabelKeys;
+10
View File
@@ -64,6 +64,7 @@
@implementation UIxComponent
static NSMutableArray *amPmLabelKeys = nil;
static NSMutableArray *dayLabelKeys = nil;
static NSMutableArray *abbrDayLabelKeys = nil;
static NSMutableArray *monthLabelKeys = nil;
@@ -72,6 +73,10 @@ static SoProduct *commonProduct = nil;
+ (void)initialize {
if (dayLabelKeys == nil) {
amPmLabelKeys = [[NSMutableArray alloc] initWithCapacity:2];
[amPmLabelKeys addObject:@"AM"];
[amPmLabelKeys addObject:@"PM"];
dayLabelKeys = [[NSMutableArray alloc] initWithCapacity:7];
[dayLabelKeys addObject:@"Sunday"];
[dayLabelKeys addObject:@"Monday"];
@@ -124,6 +129,11 @@ static SoProduct *commonProduct = nil;
}
}
+ (NSArray *) amPmLabelKeys
{
return (NSArray *) amPmLabelKeys;
}
+ (NSArray *) abbrDayLabelKeys
{
return (NSArray *) abbrDayLabelKeys;
+1
View File
@@ -394,6 +394,7 @@ Date.prototype.format = function(localeProvider, format) {
'%H': this.getHours(), // hour (00..23)
'%M': this.getMinutes() }; // minute (00..59)
val['%I'] = val['%H'] > 12 ? val['%H'] % 12 : val['%H']; // hour (01..12)
val['%p'] = val['%H'] < 12 ? l('AM') : l('PM'); // locale's equivalent of either AM or PM
val['%d'] = (val['%d'] < 10 ? '0' : '') + val['%d'];
val['%e'] = (val['%e'] < 10 ? ' ' : '') + val['%e'];