本文介绍了Powershell Golf:下一个工作日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 powershell 查找下一个工作日?
How to find next business day with powershell ?
推荐答案
这也很短(但使用别名):
This is pretty short too (but uses aliases):
,(1,2-eq7-(date).dayofweek)|%{(date)+"$(1+$_[0])"}
在一个声明中:
(date)+"$(1+$(@(1,2-eq7-(date).dayofweek)))"
关于这种方法的一些注意事项:
A few notes about this approach:
在 Powershell(至少 v1)中,与集合的比较返回条件为真的项目,例如:
In Powershell (v1 at least), comparisons with collections return items where the condition is true, for example:
PS>1,2 -eq 1
PS>1
我正在利用规则today + 1
的实际例外来计算下一个工作日的事实只有周五(+3 天)和周六(+2天).
I'm taking advantage of the fact that the actual exceptions to the rule today + 1
to calculate the next business day are only Friday (+3 days) and Saturday (+2 days).
这篇关于Powershell Golf:下一个工作日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!