feat(dm): add first / last message date, dm duration and overall messages

This commit is contained in:
Samuel 2024-12-14 16:27:02 +01:00
parent bce22b1c7f
commit e45812534b
12 changed files with 495 additions and 65 deletions

10
src/lib/date.ts Normal file
View file

@ -0,0 +1,10 @@
// https://stackoverflow.com/a/15289883
export const getDistanceBetweenDatesInDays = (a: Date, b: Date) => {
const _MS_PER_DAY = 1000 * 60 * 60 * 24;
// Discard the time and time-zone information.
const utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
const utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
return Math.floor((utc2 - utc1) / _MS_PER_DAY);
};