feat: added budget from schedule

This commit is contained in:
2024-07-23 11:41:19 +02:00
commit e51e42efa8
9 changed files with 726 additions and 0 deletions

26
lib/dates.js Normal file
View File

@@ -0,0 +1,26 @@
import { add, parse, format } from 'date-fns';
const startNow = new Date();
export function addFromFrequency(date, frequency, f = 'yyyy-MM') {
const toAdd = {};
switch (frequency) {
case 'daily':
toAdd.days = 1;
break;
case 'weekly':
toAdd.weeks = 1;
break;
case 'monthly':
toAdd.months = 1;
break;
case 'yearly':
toAdd.years = 1;
break;
default:
break;
}
return format(add(parse(date, f, startNow), toAdd), f);
}