【发布时间】:2015-07-17 13:20:56
【问题描述】:
我正在尝试使用我的代码来获得下一个工作日,但它无法正常工作。它只是显示第二天。我试图检查其他问题以找到错误,但我仍然无法弄清楚。
这个问题适用于我自己,但不完全是:
How to exclude weekends between two dates using Moment.js
$scope.businessDay = new Date();
if (moment().day() === 5) { // friday, show monday
// set to monday
$scope.businessDay=moment().weekday(8).format("MMMM Do YYYY");
}
if (moment().day() === 6) { // saturday, show monday
// set to monday
$scope.businessDay=moment().weekday(8).format("MMMM Do YYYY");
}
else { // other days, show next day
$scope.businessDay= moment().add('days', 1).format("MMMM Do YYYY");
}
【问题讨论】:
-
你需要一个包含所有假期的数组,如果还有的话也要检查
标签: javascript momentjs