Dates and times di Delphi

Tipe data TDateTime
Untuk memproses Tanggal dan waktu tergantung pada variabel TDateTime.Objek ini digunakan untuk menyimpan kombinasi tanggal dan waktu. TDateTime juga digunakan untuk menyimpan nilai-nilai hanya tanggal atau waktu – waktu dan nilai masing-masing tanggal diabaikan. TDateTime didefinisikan dalam unit System. Tanggal dan rutinitas konstanta didefinisikan di SysUtils dan unit DateUtils.

Mari kita lihat beberapa contoh sederhana yang memberikan nilai ke variabel TDateTime:
var
date1, date2, date3 : TDateTime; // TDateTime variables
begin
date1 := Yesterday; // Set to the start of yesterday
date2 := Date; // Set to the start of the current day
date3 := Tomorrow; // Set to the start of tomorrow
date4 := Now; // Set to the current day and time
end;

date1 is set to something like 12/12/2002 00:00:00
date2 is set to something like 13/12/2002 00:00:00
date3 is set to something like 14/12/2002 00:00:00
date4 is set to something like 13/12/2002 08:15:45

beberapa Penamaan nilai TDateTime

Short and long month names
adapun kode nya:
catatan: indey array dimulai dari 1.
var
month : Integer;
begin
for month := 1 to 12 do // tampilkan
begin
ShowMessage(ShortMonthNames[month]);
ShowMessage(LongMonthNames[month]);
end;
end;

program akan menampilakn pesan nama pendek dan panjang bulan :

Jan
January
Feb
February
Mar
March
Apr
April
May
May
Jun
June
Jul
July
Aug
August
Sep
September
Oct
October
Nov
November
Dec
December


Short and long day names

perlu diingatkan bahwa index array dari hari dimulai dari 1=sunday (minggu)

adapun kodingnya:
var
day : Integer;
begin
for day := 1 to 12 do // Display the short and long day names
begin
ShowMessage(ShortDayNames[day]);
ShowMessage(LongDayNames[day]);
end;
end;

maka program akan menampilkan :

Sun
Sunday
Mon
Monday
Tue
Tuesday
Wed
Wednesday
Thu
Thursday
Fri
Friday
Sat
Saturday

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s