Advertisement
Wasif_Hasan_

JulianDate.ps1

Aug 13th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Converts Gregorian Date to Julian date Coded by Wasif Hasan
  2. # Syntax: JulianDate.ps1 YYYY MM DD [-C]
  3. # -C refers to current date
  4. #####################################################################
  5.  
  6. If ($args[0] -eq "-C") {
  7.   $Y = (Get-Date).Year; $M = (Get-Date).Month; $D = (Get-Date).Day
  8. } Else {
  9.   $Y = $args[0]; $M = $args[1]; $D = $args[2]
  10. }
  11. $M1 = ($M-14)/12
  12. $Y1 = $Y+4800
  13. $JDate = 1461*($Y1+$M1)/4+367*($M-2-12*$M1)/12-(3*(($Y1+$M1+100)/100))/4+$D-32075
  14. $JDate = [Math]::Truncate($JDate)
  15. Write-Host "Given Date  :`t$($D)/$($M)/$($Y)"
  16. Write-Host "Julian Date :`t$($JDate)"
  17.  
  18.  
  19. #####################################################################
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement