joanllenas / ngx-date-fns

⏳ date-fns pipes for Angular
163 stars 14 forks source link

Add dfnsParseIso pipe #337

Closed toverux closed 3 years ago

toverux commented 3 years ago

Hi! I found myself needing a dfnsParseIso pipe since the dates coming from my server API are ISO-formatted (ie. not localized) and since date-fns 2.0 doesn't supports strings anymore.

import { Pipe, PipeTransform } from '@angular/core';
import { parseISO } from 'date-fns';

@Pipe({
    name: 'myDfnsParseIso',
    pure: true
})
export class DfnsParseIsoPipe implements PipeTransform {
    public transform(value: string, options?: { additionalDigits?: 0 | 1 | 2 }): Date {
        return parseISO(value, options);
    }
}
joanllenas commented 3 years ago

New pipe included in v6.5.0. See https://github.com/joanllenas/ngx-date-fns/releases/tag/v6.5.0

toverux commented 3 years ago

Thanks!