Home  |  Delphi .net Home  |  System.Globalization.DateTimeFormatInfo  |  GetEra Method
GetEra  
Method  
Get the Era number for the given Era name
DateTimeFormatInfo Class
System.Globalization NameSpace
CF1.  Function GetEra ( EraName : String; ) : Integer;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns the Era Number for the given EraName.
 
For the Gregorian Calendar, .Net only supports dates from 1st January 0001 AD, and hence only one era : 'A.D.'
Microsoft MSDN Links
System.Globalization
System.Globalization.DateTimeFormatInfo
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Globalization;

var
  britCulture    : System.Globalization.CultureInfo;

  dateTimeFormat : System.Globalization.DateTimeFormatInfo;

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

  // Display the Era number for 'A.D.'
  dateTimeFormat := britCulture.DateTimeFormat;

  Console.WriteLine('A.D. is era number {0}',
                    dateTimeFormat.GetEra('A.D.').ToString);

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