How can I bring all the Events that begin inside this day to 30 days?
I'd done this pipe but it doesn't work
there is an array of events and needs to bring only the events that have dateStart
inside 30 days from now, how can I do it work? the compare of dateStart
and Date.now()
+ 30 days
import { Pipe, PipeTransform } from '@angular/core';
import { SupplyEvent } from "../../models/supplyEvent";
@Pipe({
name: 'toBeginFilter'
})
export class ToBeginFilterPipe implements PipeTransform {
toBegin (SupplyEvent) {
if (SupplyEvent.dateStart >= Date.now() + (30)) {
return SupplyEvent
}
}
transform(SupplyEvents: SupplyEvent[]): any {
if (!SupplyEvents) return SupplyEvents
return SupplyEvents.filter(this.toBegin)
}
}