diff options
Diffstat (limited to 'date-fns/src/nextMonday/index.ts')
-rw-r--r-- | date-fns/src/nextMonday/index.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/date-fns/src/nextMonday/index.ts b/date-fns/src/nextMonday/index.ts new file mode 100644 index 0000000..201b8c6 --- /dev/null +++ b/date-fns/src/nextMonday/index.ts @@ -0,0 +1,25 @@ +import requiredArgs from '../_lib/requiredArgs/index' +import nextDay from '../nextDay/index' +import toDate from '../toDate/index' + +/** + * @name nextMonday + * @category Weekday Helpers + * @summary When is the next Monday? + * + * @description + * When is the next Monday? + * + * @param {Date | number} date - the date to start counting from + * @returns {Date} the next Monday + * @throws {TypeError} 1 argument required + * + * @example + * // When is the next Monday after Mar, 22, 2020? + * const result = nextMonday(new Date(2020, 2, 22)) + * //=> Mon Mar 23 2020 00:00:00 + */ +export default function nextMonday(date: Date | number): Date { + requiredArgs(1, arguments) + return nextDay(toDate(date), 1) +} |