mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-10 18:36:15 -08:00
feat: add moment.js based date pipe
This commit is contained in:
3 files changed
+29
-1
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
import { MomentDatePipe } from './moment-date.pipe';
|
||||||
|
|
||||||
|
describe('Pipe: MomentDatee', () => {
|
||||||
|
it('create an instance', () => {
|
||||||
|
const pipe = new MomentDatePipe();
|
||||||
|
expect(pipe).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,10 @@ import { HeaderComponent } from './components/';
|
|||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { MaterialModule } from 'app/material.module';
|
import { MaterialModule } from 'app/material.module';
|
||||||
import { FilterPipeModule } from 'ngx-filter-pipe';
|
import { FilterPipeModule } from 'ngx-filter-pipe';
|
||||||
|
import { MomentDatePipe } from './pipes/moment-date.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [HeaderComponent],
|
declarations: [HeaderComponent, MomentDatePipe],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FilterPipeModule,
|
FilterPipeModule,
|
||||||
@@ -24,6 +25,7 @@ import { FilterPipeModule } from 'ngx-filter-pipe';
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
HeaderComponent,
|
HeaderComponent,
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
|
MomentDatePipe,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in new issue
Block a user