在 Powershell 中计算日历周、工作日和年份的日期

Calculate date from calendar week, weekday and year in powershell

如何在 powershell 中根据 ISO 8601 日历周、工作日和年份计算日期?

示例:日历第 3 周,第 4 工作日,2017 年应该 return 日期对象 1/19/2017

使用模块IsoDates.psm1 by Joel Bennett
就这么简单:

## Q:\Test17\SO_41743960.ps1
Import-Module 'Q:\test\posh\IsoDates.psm1'

"IsoDayofWeek for {0:D} is {1} vs {2}" -f `
      (Get-Date "01/15/2017"),
      (Get-ISODayOfWeek "01/15/2017"),
      ((Get-Date "01/15/2017").DayOfweek.value__)
"ISODateString for today is {0}" -F (Get-ISODateString)
"ConvertFrom-ISODateString {0} is {1:D}" -f "2017-W01-1",
      (ConvertFrom-ISODateString("2017-W01-1"))

返回此输出(在我的德语语言环境 pc 上):

IsoDayofWeek for Sonntag, 15. Januar 2017 is 7 vs 0
ISODateString for today is 2017-W03-4
ConvertFrom-ISODateString 2017-W01-1 is Montag, 2. Januar 2017