Last active
November 12, 2017 12:09
-
-
Save dninomiya/31b5c46d94d9daaad861553cd706be74 to your computer and use it in GitHub Desktop.
age pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'age' | |
}) | |
export class AgePipe implements PipeTransform { | |
transform(value: number, args?: any): any { | |
const ageDate = new Date(Date.now() - value); | |
return Math.abs(ageDate.getUTCFullYear() - 1970); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment