Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for chineseyear.ps

(view source code of chineseyear.ps as plain text)

  1. param(
  2. 	[parameter( Mandatory = $true, HelpMessage = "Enter a year between 1900 and 2100:" )]
  3. 	[ValidateRange(1900,2100)]
  4. 	[int]$myYear
  5. )
  6.  
  7. $names = "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"
  8.  
  9. Write-Host $myYear -ForegroundColor White -NoNewline
  10. if ( $myYear -lt ( Get-Date ).Year ) {
  11. 	Write-Host " was" -NoNewline
  12. } elseif ( $myYear -gt ( Get-Date ).Year ) {
  13. 	Write-Host " will be" -NoNewline
  14. } else {
  15. 	Write-Host " is" -NoNewline
  16. }
  17. Write-Host " a Chinese year of the " -NoNewline
  18. Write-Host $names[ ( $myYear - 1900 ) % 12 ] -ForegroundColor White
  19.  

page last uploaded: 2017-04-06, 13:33