restructured and clean up

This commit is contained in:
Ren Amamiya
2023-03-05 09:27:16 +07:00
parent 8b86aca23c
commit 13dda65a39
27 changed files with 69 additions and 212 deletions

View File

@@ -1,3 +1,4 @@
// get X days ago with user provided date
export const daysAgo = (numOfDays, date = new Date()) => {
const daysAgo = new Date(date.getTime());
daysAgo.setDate(date.getDate() - numOfDays);
@@ -5,6 +6,7 @@ export const daysAgo = (numOfDays, date = new Date()) => {
return daysAgo;
};
// get X hours ago with user provided date
export const hoursAgo = (numOfHours, date = new Date()) => {
const hoursAgo = new Date(date.getTime());
hoursAgo.setHours(date.getHours() - numOfHours);
@@ -12,6 +14,7 @@ export const hoursAgo = (numOfHours, date = new Date()) => {
return hoursAgo;
};
// convert date to unix timestamp
export const dateToUnix = (_date?: Date) => {
const date = _date || new Date();