feat: add filters to drafts (#1631)

* feat: add filters to drafts

Co-authored-by: Guilherme Diniz <guilhermedassumpcao@gmail.com>
This commit is contained in:
Tom Moor
2020-11-08 22:33:52 -08:00
committed by GitHub
parent 14e0ed8108
commit 4e7a1cd121
7 changed files with 184 additions and 28 deletions

23
shared/utils/date.js Normal file
View File

@@ -0,0 +1,23 @@
// @flow
import subDays from "date-fns/sub_days";
import subMonth from "date-fns/sub_months";
import subWeek from "date-fns/sub_weeks";
import subYear from "date-fns/sub_years";
export function subtractDate(
date: Date,
period: "day" | "week" | "month" | "year"
) {
switch (period) {
case "day":
return subDays(date, 1);
case "week":
return subWeek(date, 1);
case "month":
return subMonth(date, 1);
case "year":
return subYear(date, 1);
default:
return date;
}
}