我看到了这篇博客文章,决定为法国发布这个。下面是一个获取所有法国假日的 PowerShell 函数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| function Get-FrenchHoliday { param ( [int] $Year = (Get-Date).Year,
[ValidateSet("alsace-moselle", "guadeloupe", "guyane", "la-reunion", "martinique", "mayotte", "metropole", "nouvelle-caledonie", "polynesie-francaise", "saint-barthelemy", "saint-martin", "saint-pierre-et-miquelon", "wallis-et-futuna")] [string] $Area = 'metropole',
[switch] $NextOnly )
$url = "https://calendrier.api.gouv.fr/jours-feries/$Area/$Year.json"
$holidays = Invoke-RestMethod -Uri $url -UseBasicParsing
foreach ($obj in $holidays.PSObject.Properties) { if (-Not ($NextOnly.IsPresent) -or (((([DateTime]$obj.Name).Ticks) - (Get-Date).Ticks) -gt 0)) { Write-Host "$($obj.Value) : $($obj.Name)" } } }
|
运行上面的函数,然后运行这个命令:
或者,提交额外的参数以获取特定地区的特定假日:
1
| Get-FrenchHoliday -NextOnly -Area guyane
|
1
| Get-FrenchHoliday -Area "alsace-moselle" -Year 2024
|