EBRAHIMJAN
سه شنبه 30 آذر 1389, 12:29 عصر
با سلام من تو سايت delphi.about چند تا تابع زمان و تاريخ ديدم و چون تازه كارم نمي دونستم چطور از اين توابع استفاده كنم گفتم اينجا قرار بدم تا دوستان تو اين زمينه كمكم كنند اگه امكانش هست اين مثالها رو همراه با سورس قرار بديد كه بهتر قابل درك باشه؟ اين هم تابع اول:
CompareDate
Declaration
type TValueRelationship = -1..1
function CompareDate(const ADate, BDate: TDateTime) : TValueRelationship
description
Compares two TDateTime values (returns "less", "equal" or "greater"). Ignores the Time part if both values "fall" on the same day.
TValueRelationship represents the relationship between two values. Each of three TValueRelationship values has a "liked" symbolic constant:
-1 [LessThanValue] The first value is less than the second value.
0 [EqualsValue] The two values are equal.
1 [GreaterThanValue] The first value is greater than the second value.
CompareDate results in:
LessThanValue if ADate occurs on a day prior to the Date part of the BDate.
EqualsValue if date parts of both ADate and BDate are the same, ignoring the Time part.
GreaterThanValue if ADate occurs on a day that follows the Date part of the BDate.
Example
var ThisMoment, AnotherMoment : TDateTime;
ThisMoment := Now;
AnotherMoment := IncADay(ThisMoment, 5); //adds 5 days
//CompareDate(ThisMoment, AnotherMoment) returns LessThanValue (-1)
//CompareDate(AnotherMoment, ThisMoment) returns GreaterThanValue (1)
CompareDate
Declaration
type TValueRelationship = -1..1
function CompareDate(const ADate, BDate: TDateTime) : TValueRelationship
description
Compares two TDateTime values (returns "less", "equal" or "greater"). Ignores the Time part if both values "fall" on the same day.
TValueRelationship represents the relationship between two values. Each of three TValueRelationship values has a "liked" symbolic constant:
-1 [LessThanValue] The first value is less than the second value.
0 [EqualsValue] The two values are equal.
1 [GreaterThanValue] The first value is greater than the second value.
CompareDate results in:
LessThanValue if ADate occurs on a day prior to the Date part of the BDate.
EqualsValue if date parts of both ADate and BDate are the same, ignoring the Time part.
GreaterThanValue if ADate occurs on a day that follows the Date part of the BDate.
Example
var ThisMoment, AnotherMoment : TDateTime;
ThisMoment := Now;
AnotherMoment := IncADay(ThisMoment, 5); //adds 5 days
//CompareDate(ThisMoment, AnotherMoment) returns LessThanValue (-1)
//CompareDate(AnotherMoment, ThisMoment) returns GreaterThanValue (1)