原文地址:http://powershell.com/cs/blogs/tips/archive/2010/06/02/filtering-day-of-week.aspx

原文:

Filtering Day of Week

You can also use this little helper function if you run scripts every day and want to make sure they don't do anything on weekends:

function is-Weekend { (Get-Date).DayOfWeek -gt 5 }

You can use it like this:

If (is-Weekend) { 'no service at weekends' } else { 'Heya, time to work' }

 

翻译:

判断是否是周末

如果想要判断当前是否是周末,可以用下面这个函数:

function is-Weekend { (Get-Date).DayOfWeek -gt 5 }

然后这样调用:

If (is-Weekend) { '周末休息' } else { '嘿嘿,工作了' }

 

 

笔记:

Get-DateDayOfWeek方法,只要这个数大于5,那么肯定就是周末了。

相关文章:

  • 2021-09-22
  • 2021-10-11
  • 2021-09-26
  • 2021-08-19
  • 2022-12-23
  • 2022-02-02
  • 2021-11-18
  • 2021-07-15
猜你喜欢
  • 2022-01-16
  • 2021-07-08
  • 2022-02-22
  • 2021-12-03
  • 2022-02-09
  • 2022-01-21
  • 2021-11-14
相关资源
相似解决方案