Skip to content

DatePipe define global default pattern #11376

@fank

Description

@fank

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Currently the default pattern is mediumDate but in a other language like german the default pattern should be ddMMyy

Current behavior
Overwrite pattern on every pipe:

<p>{{ myDate | date:'ddMMyy' }}</p>
<p>{{ myOtherDate | date:'ddMMyy' }}</p>
<p>{{ otherVar }}</p>
<p>{{ myOtherOtherDate | date:'MMyyDD' }}</p>

Expected/desired behavior
There should be a variable like LOCAL_ID shich can be overwritten:

@NgModule({
    providers: [
        {provide: LOCAL_PIPE_DATE_PATTERN, useValue: 'ddMMyy'},
    ],
})
export class AppModule {}

So we can use:

<p>{{ myDate | date }}</p>
<p>{{ myOtherDate | date }}</p>
<p>{{ otherVar }}</p>
<p>{{ myOtherOtherDate | date:'MMyyDD' }}</p>

What is the motivation / use case for changing the behavior?
In some languages like german we want dates like '2016-02-01' written '01.02.2016' so, it would be much better to define a default pattern per "language" instead of set the pattern on every pipe.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: [all]
  • Language: [all]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonIssues related to APIs in the @angular/common packagearea: i18nIssues related to localization and internationalizationfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions