mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 20:59:28 -05:00
mealplandialog date range working and moving
This commit is contained in:
14
vue3/src/utils/date_utils.ts
Normal file
14
vue3/src/utils/date_utils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {DateTime} from "luxon";
|
||||
|
||||
/**
|
||||
* shifts a range of dates/any array of dates by the number of days given in the day modifier (can be positive or negative)
|
||||
* @param dateRange
|
||||
* @param dayModifier
|
||||
*/
|
||||
export function shiftDateRange(dateRange: Date[], dayModifier: number){
|
||||
let newDateRange: Date[] = []
|
||||
dateRange.forEach(date => {
|
||||
newDateRange.push(DateTime.fromJSDate(date).plus({'days': dayModifier}).toJSDate())
|
||||
})
|
||||
return newDateRange
|
||||
}
|
||||
Reference in New Issue
Block a user