本文介绍了在Javascript中添加/减去工作日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个Date.prototype.addBusDays函数
,它将一个整数作为添加到日期的工作天数。

I need a Date.prototype.addBusDays functionthat'll take an integer as the number of working days to add to the date.

然而,有两个考虑:1.周末,假期(假设我想像一个预设的数组来比较,如果开始日期和结束日期包含3个假期,那么你推出结束日期3)

However, there are two considerations: 1. Weekends, 2. Holidays (which I imagine would be a preset array to compare against. If beginning date and end date contain 3 holidays, then you push out the end date by 3)

我在网上遇到了一些脚本,我可以想到的一个困境就是让你说,首先处理所有的周末,然后你做假期,如果你+1了到假期),您的结束日期再次被推入一个周末...<

任何想法?
谢谢!

I have come across some scripts online, one dilemma I can think of is, lets say you address all the weekends first, then you do the holidays, what if you +1 day (due to holiday), and your end date is pushed into a weekends again...<

Any ideas?Thanks!

编辑:

这是我正在开发的调度工具的一部分,这意味着日期将与连接在一起的任务相关联。将1天添加到任务中,将触发重新计算与之相关的所有日期,可能是数据库中的所有日期。

This is a part of a scheduling tool I am developing, which mean the dates will be tied to tasks which are linked together. Adding 1 day to a task, will trigger a recalculation of everything tied to it, potentially all dates in the database.

推荐答案

会做一个循环。继续添加天数,直到您打了一天。

I would do a loop. Keep adding days until you hit a day that works.

这篇关于在Javascript中添加/减去工作日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:45