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. ## Start of script 
  28.  
  29. # Create three new calendars 
  30. $grCal = new-object System.Globalization.GregorianCalendar 
  31. $hiCal = new-object System.Globalization.HijriCalendar 
  32. $jaCal = new-object System.Globalization.JapaneseLunisolarCalendar 
  33.  
  34. # Display them 
  35. Display($grCal); 
  36. Display($hiCal); 
  37. Display($jaCal); 
  38.  
  39. [enum]::GetNames([System.Globalization.CalendarAlgorithmType]) 

No comments: