Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: src/extensions/experimental/i18n.js

Issue 7244008: Change timeType and dateType in i18n date format API into timeStyle and dateStyle to match the pr... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Regex fix. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/extensions/experimental/datetime-format.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/extensions/experimental/i18n.js
===================================================================
--- src/extensions/experimental/i18n.js (revision 8401)
+++ src/extensions/experimental/i18n.js (working copy)
@@ -145,9 +145,8 @@
* @param {Object} locale - locale object to pass to formatter.
* @param {Object} settings - formatting flags:
* - skeleton
- * - dateType
- * - timeType
- * - calendar
+ * - dateStyle
+ * - timeStyle
* @private
* @constructor
*/
@@ -161,25 +160,37 @@
cleanSettings['skeleton'] = settings['skeleton'];
} else {
cleanSettings = {};
- if (settings.hasOwnProperty('dateType')) {
+ if (settings.hasOwnProperty('dateStyle')) {
+ var ds = settings['dateStyle'];
+ if (!/^(short|medium|long|full)$/.test(ds)) ds = 'short';
+ cleanSettings['dateStyle'] = ds;
+ } else if (settings.hasOwnProperty('dateType')) {
+ // Obsolete. New spec requires dateStyle, but we'll keep this around
+ // for current users.
+ // TODO(cira): Remove when all internal users switch to dateStyle.
var dt = settings['dateType'];
- if (!/^short|medium|long|full$/.test(dt)) dt = 'short';
- cleanSettings['dateType'] = dt;
+ if (!/^(short|medium|long|full)$/.test(dt)) dt = 'short';
+ cleanSettings['dateStyle'] = dt;
}
- if (settings.hasOwnProperty('timeType')) {
+ if (settings.hasOwnProperty('timeStyle')) {
+ var ts = settings['timeStyle'];
+ if (!/^(short|medium|long|full)$/.test(ts)) ts = 'short';
+ cleanSettings['timeStyle'] = ts;
+ } else if (settings.hasOwnProperty('timeType')) {
+ // TODO(cira): Remove when all internal users switch to timeStyle.
var tt = settings['timeType'];
- if (!/^short|medium|long|full$/.test(tt)) tt = 'short';
- cleanSettings['timeType'] = tt;
+ if (!/^(short|medium|long|full)$/.test(tt)) tt = 'short';
+ cleanSettings['timeStyle'] = tt;
jungshik at Google 2011/06/24 16:33:47 given that this will go away later, I wouldn't say
Nebojša Ćirić 2011/06/24 16:43:22 I am not going to refactor - current code makes it
}
}
// Default is to show short date and time.
if (!cleanSettings.hasOwnProperty('skeleton') &&
- !cleanSettings.hasOwnProperty('dateType') &&
- !cleanSettings.hasOwnProperty('timeType')) {
- cleanSettings = {'dateType': 'short',
- 'timeType': 'short'};
+ !cleanSettings.hasOwnProperty('dateStyle') &&
+ !cleanSettings.hasOwnProperty('timeStyle')) {
+ cleanSettings = {'dateStyle': 'short',
+ 'timeStyle': 'short'};
}
locale = v8Locale.__createLocaleOrDefault(locale);
@@ -249,7 +260,7 @@
cleanSettings['pattern'] = settings['pattern'];
} else if (settings.hasOwnProperty('style')) {
var style = settings['style'];
- if (!/^decimal|currency|percent|scientific$/.test(style)) {
+ if (!/^(decimal|currency|percent|scientific)$/.test(style)) {
style = 'decimal';
}
cleanSettings['style'] = style;
« no previous file with comments | « src/extensions/experimental/datetime-format.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698