Monday, 31 October 2011

Show-CalendarAlgorithm.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script re-implements an MSDN Sample showing the  
  4.     CalendarAlgorithmType enumeration.  
  5. .DESCRIPTION 
  6.     This script creates there calendars and displays  
  7.     algorithm type, 
  8. .NOTES 
  9.     File Name  : Show-CalendarAlgorithm.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN sample posted to: 
  16.         http://msdn.microsoft.com/en-us/library/system.globalization.calendaralgorithmtype.aspx 
  17. .EXAMPLE 
  18.      
  19. #> 
  20.  
  21. # Helper function 
  22. Function Display{ 
  23. Param ([System.Globalization.Calendar] $c) 
  24. $name = $c.ToString().PadRight(50, '.') 
  25. "{0} {1}" -f $name, $c.AlgorithmType 
  26. } 
  27.  
  28. ## Start of script 
  29.  
  30. # Create three new calendars 
  31. $grCal = new-object System.Globalization.GregorianCalendar 
  32. $hiCal = new-object System.Globalization.HijriCalendar 
  33. $jaCal = new-object System.Globalization.JapaneseLunisolarCalendar 
  34.  
  35. # Display them 
  36. Display($grCal); 
  37. Display($hiCal); 
  38. Display($jaCal); 
  39.  
  40. [enum]::GetNames([System.Globalization.CalendarAlgorithmType]) 

No comments: