Home  |  Delphi .net Home  |  System.Globalization.DateTimeFormatInfo  |  GetEraName Method
GetEraName  
Method  
Get the full Era name for the specified era number
DateTimeFormatInfo Class
System.Globalization NameSpace
CF1.  Function GetEraName ( Era : Integer; ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns the name of the Era for the given Era number.
 
For the Gergorian Calendar, used in Britain, there is only one era covered : A.D. since date handlin in .Net starts at 00:00:00 on 1st January 0001 AD.
Microsoft MSDN Links
System.Globalization
System.Globalization.DateTimeFormatInfo
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Globalization;

var
  britCulture    : System.Globalization.CultureInfo;
  britCal        : System.Globalization.Calendar;

  dateTimeFormat : System.Globalization.DateTimeFormatInfo;

  era            : Integer;
  eras           : Array of Integer;

begin
  // Set up British culture and calendar
  britCulture := CultureInfo.Create('en-GB');
  britCal     := britCulture.Calendar;

  // Display the British Eras :
  eras           := britCal.Eras;
  dateTimeFormat := britCulture.DateTimeFormat;
  for era := 0 to Length(eras)-1 do
    Console.WriteLine('British Era {0} = {1}',
              eras[era].ToString,
              dateTimeFormat.GetEraName(eras[era]));

  Console.ReadLine;
end.
Show full unit code
  British Era 1 = A.D.
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author