SHARE
TWEET

Long service leave days

Flimbot Feb 19th, 2020 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $State = "QLD"
  2. $StartDate = (Get-Date -Date '25/06/2012')
  3. $LongServiceElligible = $StartDate.AddYears(7)
  4. $FortnightRDO = (Get-Date -Date '02/03/2018') #Enter start date
  5.  
  6. #https://data.gov.au/dataset/australian-holidays-machine-readable-dataset
  7.  
  8. $PublicHols = @()
  9. @(
  10.     "https://data.gov.au/dataset/b1bc6077-dadd-4f61-9f8c-002ab2cdff10/resource/56a5ee91-8e94-416e-81f7-3fe626958f7e/download/australianpublicholidays-201415.csv---australianpublicholidays.csv.csv",
  11.     "https://data.gov.au/dataset/b1bc6077-dadd-4f61-9f8c-002ab2cdff10/resource/13ca6df3-f6c9-42a1-bb20-6e2c12fe9d94/download/australianpublicholidays-201516.csv",
  12.     "https://data.gov.au/dataset/b1bc6077-dadd-4f61-9f8c-002ab2cdff10/resource/a24ecaf2-044a-4e66-989c-eacc81ded62f/download/australianpublicholidays-201617.csv",
  13.     "https://data.gov.au/dataset/b1bc6077-dadd-4f61-9f8c-002ab2cdff10/resource/253d63c0-af1f-4f4c-b8d5-eb9d9b1d46ab/download/australianpublicholidays-201718.csv",
  14.     "https://data.gov.au/dataset/b1bc6077-dadd-4f61-9f8c-002ab2cdff10/resource/429f3cb9-44e8-4032-9e48-6febace6c47f/download/australianpublicholidays-2019-incomplete.csv"
  15. ) | %{
  16.     $PublicHols += @(Invoke-WebRequest $_ | %{$_.Content} | ConvertFrom-CSV | ?{$_.'Applicable To' -match $State} | %{[DateTime]::ParseExact($_.Date,"yyyyMMdd",[System.Globalization.CultureInfo]::InvariantCulture)})
  17. }
  18.  
  19. $DaysOff  = 0
  20. $DaysLeft = 0
  21.  
  22. for( $CurDay = (Get-Date).Date ; $CurDay -lt $LongServiceElligible ; $CurDay = $CurDay.AddDays(1) ) {
  23.     if( $CurDay -eq $FortnightRDO ) {
  24.         #RDO
  25.         $DaysOff++
  26.  
  27.         #Calculate next
  28.         $FortnightRDO = $FortnightRDO.AddDays(14)
  29.     }
  30.     elseif( $CurDay.DayOfWeek -match "Sat|Sun" ) {
  31.         #Weekend
  32.         $DaysOff++
  33.     }
  34.     elseif( $PublicHols.Contains($CurDay) ) {
  35.         #Public holiday
  36.         $DaysOff++
  37.     }
  38.     else {
  39.         $DaysLeft++
  40.     }
  41. }
  42.  
  43. Write-Host "Days until LSL:" $DaysLeft
  44. Write-Host "(not considering Annual Leave days)"
  45. Write-Host "Days off before LSL:" $DaysOff
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top