Override default skeleton pattern
MBulli opened this issue · 2 comments
Is your feature request related to a problem? Please describe.
Currently it is not possible to change the skeletons pattern. The German local uses "d.M.y" for yMd, but some users may prefer the also common "dd.MM.y" pattern with leading zeros for the day and month.
Describe the solution you'd like
I understand that Dart follows the Unicode CLDR data and that changing the pattern for the yMd skeleton is not desirable. However, a way to override the default pattern would solve the above problem.
Describe alternatives you've considered
Using an explicit pattern would be one solution, but this would break support for other locals such as en_US.
Additional context
The way initializeDateFormatting()
is currently written would allow easy customization of the datetime symbol map.
But initializeDateSymbols()
is an internal function, so in practice you can't customize the patterns.
Additionally, DateSymbols
has no nice API to actually modify its data.
This seems related to #188, and the makeshift solution in #188 (comment).
Thank you. I didn't see the initializeDateFormattingCustom()
function. That's basically what I was suggesting here, so feel free to close this issue.
I adapted your code like this:
final symbols = dateTimeSymbolMap()['de'] as DateSymbols;
var patterns = dateTimePatternMap()['de'];
if (patterns != null) {
patterns = Map.of(patterns);
patterns['yMd'] = 'dd.MM.y';
}
initializeDateFormattingCustom(
locale: 'de',
symbols: symbols,
patterns: patterns,
);