Selamat Datang !

Selamat Datang di Yus Waroeng Software ! Saya ucapkan terima kasih anda sudah masuk ke blog kami, dimana anda dapat mencari informasi Software Aplikasi yang anda butuhkan dan berbagi ilmu pemograman.
Cari Artikel

Saturday, March 29, 2008

Delphi DateTime Tutorial

Yus Waroeng Software Blog’s Delphi Tutorial

pembuatan delay dalam satuan milidetik

procedure TForm1.Delay(mSec: Integer);
var StartCount: longint;
begin
StartCount:=GetTickCount;
repeat
Application.ProcessMessages;
until (GetTickCount-StartCount) >= mSec;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
{persiapkan sesuatu di sini}
Delay(5000);
{lakukan sesuatu di sini}
end;

Sumber : Mikrodata

MonthsPassed

function MonthsPassed(aFrom, anUntil: TDateTime): Integer;
begin
Result := 12 * (YearFromDate(anUntil) -
YearFromDate(aFrom)) +
MonthFromDate(anUntil) -
MonthFromDate(aFrom);
end;

AddMonthsToDate

function AddMonthsToDate(aDate: TDateTime; aNrMonths: Integer): TDateTime;
begin
Result := IncMonth(aDate, aNrMonths);
end;

GetLastDateOfMonth

function GetLastDateOfMonth(aYear, aMonth: Integer): TDateTime;
begin
Result := EncodeDate(aYear, aMonth, GetLastDayOfMonth(aYear, aMonth));
end;

GetFirstDateOfMonth

function GetFirstDateOfMonth(aYear, aMonth: Integer): TDateTime;
begin
Result := EncodeDate(aYear, aMonth, 1);
end;

GetLastDateOfYear

function GetLastDateOfYear(aYear: Integer): TDateTime;
begin
Result := EncodeDate(aYear, 12, 31);
end;

GetFirstDateOfYear

function GetFirstDateOfYear(aYear: Integer): TDateTime;
begin
Result := EncodeDate(aYear, 1, 1);
end;

GetLastDayOfMonth

function GetLastDayOfMonth(aYear, aMonth: Integer): Integer;
Const
cDAYSINMONTHS: Array[1..12] Of Integer =
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
begin
Result := cDAYSINMONTHS[aMonth];
If (aMonth = 2) And
IsLeapYear(aYear) Then
Inc(Result);
end;

DayFromDate

function DayFromDate(aDate: TDateTime): Integer;
begin
Result := GetDateRecordFromDate(aDate).Day;
end;

MonthFromDate

function MonthFromDate(aDate: TDateTime): Integer;
begin
Result := GetDateRecordFromDate(aDate).Month;
end;

0 comments:

Post a Comment

Leave Your Comment Here!

Komentar Terbaru