This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/shared/utils/date.js
Tom Moor 4e7a1cd121 feat: add filters to drafts (#1631)
* feat: add filters to drafts

Co-authored-by: Guilherme Diniz <guilhermedassumpcao@gmail.com>
2020-11-08 22:33:52 -08:00

24 lines
522 B
JavaScript

// @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;
}
}