The DistanceBetweenDatesPipe accepts a pair of date expressions, and returns a string generated from the date-fns distanceInWords
function.
datePair | distanceBetweenDates
Here, datePair
must be an array of length 2. Each element of the array must be a string, number or Date that parses to a valid Date. There are no inline options for this pipe, but you can use the DatePipeManager to set whether the distance string contains seconds.
You can programmatically set whether the distance function shows seconds. The default value for this flag is false
.
import { DatePipeManager } from 'ng2-datefns-pipes';
export class ExampleClass {
// inject the DatePipeManager
constructor(manager: DatePipeManager) {
manager.includeSecondsInDistance(); // sets flag to always include seconds in distance
manager.doNotIncludeSecondsInDistance() // sets flag so seconds will never be included in distance
let areSecondsIncluded = manager.secondsIncludedInDistance() // returns true or false
}
}
includeSecondsInDistance()
Sets as default to include seconds in distance.
doNotIncludeSecondsInDistance()
Set as default to NOT include seconds in distance.
secondsIncludedInDistance(): boolean
Returns the current value of the includeSeconds flag.