Last active
January 12, 2024 16:09
-
-
Save JonCatmull/da9c8bb7367f1f55a4080bbc525c09ac to your computer and use it in GitHub Desktop.
Revisions
-
JonCatmull revised this gist
Mar 13, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Pipe, PipeTransform } from '@angular/core'; const ordinals: string[] = ['th','st','nd','rd']; /* * Append ordinal to number (e.g. "1st" position) * Usage: * value | ordinal:keepNumber * Example: -
JonCatmull revised this gist
Mar 13, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const ordinals: string[] = ['th','st','nd','rd']; export class OrdinalPipe implements PipeTransform { transform(n: number, keepNumber: boolean = true) { let v = n % 100; return (keepNumber?n:'') + (ordinals[(v-20)%10]||ordinals[v]||ordinals[0]); } } -
JonCatmull revised this gist
Mar 13, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; const ordinals: string[] = ['th','st','nd','rd']; /* * Turn Date into realtive date (e.g. 5 days ago) -
JonCatmull created this gist
Mar 13, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import { Pipe, PipeTransform } from '@angular/core'; const ordinals: string[] = ["th","st","nd","rd"]; /* * Turn Date into realtive date (e.g. 5 days ago) * Usage: * value | ordinal:keepNumber * Example: * {{ 23 | ordinal}} * formats to: '23rd' * Example: * {{ 23 | ordinal:false}} * formats to: 'rd' */ @Pipe({name: 'ordinal'}) export class OrdinalPipe implements PipeTransform { transform(n: number, keepNumber: boolean = true) { var v = n % 100; return (keepNumber?n:'') + (ordinals[(v-20)%10]||ordinals[v]||ordinals[0]); } }