nextThursday
返回给定日期之后的下一个星期四的日期。
javascript
import { addDays, getDay } from "date-fns";
// 示例日期
const date = new Date(); // 当前日期
// 获取下一个星期四的日期
let nextThursday = date;
while (getDay(nextThursday) !== 4) {
nextThursday = addDays(nextThursday, 1);
}
console.log("下一个星期四的日期:", nextThursday);
// 下一个星期四的日期:Thu May 16 2024 00:00:00