如何在powershell中计算ISO 8601日历周,工作日和年份的日期?
示例:日历第3周,工作日4,2017年应返回日期对象1/19/2017
答案 0 :(得分:0)
使用模块IsoDates.psm1 by Joel Bennett
它很简单:
## Q:\Test\2017\01\19\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