-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { MomentDatePipe } from './moment-date.pipe'; | ||
|
||
describe('Pipe: MomentDatee', () => { | ||
it('create an instance', () => { | ||
const pipe = new MomentDatePipe(); | ||
expect(pipe).toBeTruthy(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Pipe, PipeTransform } from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
/** | ||
* Moment.js based pipe to parse and return the provided date based on given params | ||
*/ | ||
@Pipe({ | ||
name: 'momentDate', | ||
}) | ||
export class MomentDatePipe implements PipeTransform { | ||
transform( | ||
value: string, | ||
formatToParse: string, | ||
formatToReturn = 'MMMM Do, dddd' | ||
): any { | ||
return moment(value, formatToParse).format(formatToReturn); | ||
} | ||
} |
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