ajout script

This commit is contained in:
nicolas 2023-12-16 16:41:26 +01:00
parent 2d25000938
commit 434b6c4b17

19
Dates/jours_ouvres.ps1 Normal file
View File

@ -0,0 +1,19 @@
#Script créé par Nicolas Lang - Sous licence CC-BY-SA
#https://nicolaslang.fr
$today = Get-Date
$cible = [datetime]"12/16/2016"
$feries = @([datetime]"01/01",[datetime]"05/01",[datetime]"05/08",[datetime]"07/14",[datetime]"08/15",[datetime]"11/1",[datetime]"11/11",[datetime]"12/25")
$feries += @([datetime]"04/21/2014",[datetime]"05/29/2014",[datetime]"06/09/2014",[datetime]"04/06/2015",[datetime]"05/14/2015",[datetime]"05/25/2015")
#ajoutez les jours qui sont fériés en conservant cette syntaxe
$joursouvres = 1
while ($today.ToLongDateString() -ne $cible.ToLongDateString())
{
if (($today.DayOfWeek -ne "Sunday") -and ($today.DayOfWeek -ne "Saturday") -and ($feries.tolongdatestring() -notcontains $today.tolongdatestring()))
{
$joursouvres++
}#fin if
$today = $today.AddDays(1)
}#fin while
Write-Host $joursouvres "jour(s) ouvré(s), aujourd'hui inclus"