Index: third_party/pkg/angular/lib/formatter/date.dart |
diff --git a/third_party/pkg/angular/lib/filter/date.dart b/third_party/pkg/angular/lib/formatter/date.dart |
similarity index 82% |
rename from third_party/pkg/angular/lib/filter/date.dart |
rename to third_party/pkg/angular/lib/formatter/date.dart |
index 75d528703124c26779bb932eff0f3d4afc8d660a..0268b468df77c5c7f19f1565c65b01650e676cb9 100644 |
--- a/third_party/pkg/angular/lib/filter/date.dart |
+++ b/third_party/pkg/angular/lib/formatter/date.dart |
@@ -1,4 +1,4 @@ |
-part of angular.filter; |
+part of angular.formatter_internal; |
/** |
* Formats date to a string based on the requested format. |
@@ -20,8 +20,8 @@ part of angular.filter; |
* {{ date_expression | date[:format] }} |
* |
*/ |
-@NgFilter(name:'date') |
-class DateFilter implements Function { |
+@Formatter(name:'date') |
+class Date implements Function { |
static final _MAP = const <String, String> { |
'medium': 'MMM d, y h:mm:ss a', |
'short': 'M/d/yy h:mm a', |
@@ -33,7 +33,7 @@ class DateFilter implements Function { |
'shortTime': 'h:mm a', |
}; |
- var _dfs = <String, DateFormat>{}; |
+ var _dfs = new Map<String, Map<String, DateFormat>>(); |
/** |
* [date]: Date to format either as Date object, milliseconds |
@@ -52,13 +52,13 @@ class DateFilter implements Function { |
if (date is String) date = DateTime.parse(date); |
if (date is num) date = new DateTime.fromMillisecondsSinceEpoch(date); |
if (date is! DateTime) return date; |
- var df = _dfs[format]; |
+ if (_MAP.containsKey(format)) format = _MAP[format]; |
+ var verifiedLocale = Intl.verifiedLocale(Intl.getCurrentLocale(), DateFormat.localeExists); |
+ _dfs.putIfAbsent(verifiedLocale, () => new Map<String, DateFormat>()); |
+ var df = _dfs[verifiedLocale][format]; |
if (df == null) { |
- if (_MAP.containsKey(format)) { |
- format = _MAP[format]; |
- } |
df = new DateFormat(format); |
- _dfs[format] = df; |
+ _dfs[verifiedLocale][format] = df; |
} |
return df.format(date); |
} |