Skip to content

ICU standard Stand Alone day of week with DatePipe is not supported #26922

@eetumanninen

Description

@eetumanninen

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

It's not possible to format a date to Stand Alone day of week with the DatePipe. (ICU standard c http://userguide.icu-project.org/formatparse/datetime)

Expected behavior

For example, the fi.ts locale file contains definitions for array position DaysStandalone, defined in the enum LocaleDataIndex, and if the getLocaleDayNames function is called directly with the FormStyle.StandAlone parameter everything works as expected (with Finnish I would get maanantai instead of maanantaina). However, format_date.ts getDateFormatter function does not have a case that would pass FormStyle.StandAlone to dateStrGetter. This is interesting because months have a case for both Format and StandAlone (ICU standard M and L, respectively). I would propose that cases would be added to getDateFormatter for the following cases as per in line with ICU standard:
// Day of the Week StandAlone
case 'c':
case 'cc':
case 'ccc':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Abbreviated, FormStyle.Standalone);
break;
case 'cccc':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Wide, FormStyle.Standalone);
break;
case 'ccccc':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Narrow, FormStyle.Standalone);
break;
case 'cccccc':
formatter = dateStrGetter(TranslationType.Days, TranslationWidth.Short, FormStyle.Standalone);
break;

Minimal reproduction of the problem with instructions

Here is a link to a stackblitz that shows the problem
https://stackblitz.com/edit/angular-gitter-qzhwvm

What is the motivation / use case for changing the behavior?

To be able to use angular internationalization with the DatePipe without having to resort to hacks

Environment


Angular version: 6.0.2
I have checked that there are no implementations for this in the most current angular version and have tested it with most current angular cli

Metadata

Metadata

Labels

area: commonIssues related to APIs in the @angular/common packagefeatureLabel used to distinguish feature request from other issuesfreq1: lowopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions