Created
November 15, 2020 16:04
-
-
Save SMoni/d1487b6b89707c51b260a94ab92c4c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getStartOfWeek() { | |
begin { | |
$base = [DayOfWeek]::Monday | |
} | |
process { | |
$difference = $_.DayOfWeek - $base | |
$offset = (7 + $difference) % 7 * -1 | |
$_.Date.AddDays($offset).Date | |
} | |
} | |
[DateTime]::Now | getStartOfWeek |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment