How to calculate a date from ISO 8601 calendar week, weekday and year in powershell?
Example: calendar week 3, weekday 4, year 2017 should return a date object 1/19/2017
Using the module IsoDates.psm1 by Joel Bennett
It's as easy as:
## 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"))
Returning this output (on my German locale 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