Add daysago formatter and extract common helper to reuse with indays formatter
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export function differenceInDays(fromDate, toDate) {
|
||||
return Math.round(Math.abs((beginningOfDay(toDate) - beginningOfDay(fromDate)) / (1000 * 60 * 60 * 24)))
|
||||
}
|
||||
|
||||
export function beginningOfDay(date) {
|
||||
return new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
||||
}
|
||||
Reference in New Issue
Block a user