date-vir
Version:
Easy and explicit dates and times.
18 lines (17 loc) • 549 B
JavaScript
import { parseLuxonDateTime, toLuxonDateTime } from '../full-date/luxon-date-time-conversion.js';
/**
* Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
* negative to go backwards in time.
*
* @category Calculation
* @example
*
* ```ts
* import {calculateRelativeDate} from 'date-vir';
*
* calculateRelativeDate(getNowInUserTimezone(), {days: 2});
* ```
*/
export function calculateRelativeDate(fullDate, offset) {
return parseLuxonDateTime(toLuxonDateTime(fullDate).plus(offset));
}