Title: Displaying Indonesian [or Other Language] Day of Week
Question: How to display Indonesian [or other language] Day of Week ?
Eg, displaying like this : "Tanggal 25/11/2006 adalah hari Sabtu" (in English: Day of week of 25/11/2006 is Saturday)
Answer:
You can use combination of "DayOfWeek" function with your own dayOfWeek array of String
Try this code
-------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
DateTimePicker1: TDateTimePicker;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function IndonesianDaysOfWeek(aDate: TDateTime): string;
var days: array[1..7] of string;
begin
days[1] := 'Minggu';
days[2] := 'Senin';
days[3] := 'Selasa';
days[4] := 'Rabu';
days[5] := 'Kamis';
days[6] := 'Jumat';
days[7] := 'Sabtu';
Result := days[DayOfWeek(aDate)];
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessageFmt('Tanggal %s adalah hari %s',
[FormatDateTime('dd/MM/yyyy', DateTimePicker1.Date),
IndonesianDaysOfWeek(DateTimePicker1.Date)]);
end;
end.
------------------
// end of the code