+ Next batch of examples (timespan functions)

This commit is contained in:
michael 2004-12-29 22:48:38 +00:00
parent 6aa22dc862
commit ba9de3ec61
18 changed files with 850 additions and 0 deletions

View File

@ -2728,6 +2728,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastYears">
<short>Check whether two datetimes are only a number of years apart</short>
<descr>
<p>
<var>WithinPastYears</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AYears</var> years apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="YearsBetween"/> function to calculate
the difference in years, this means that fractional years do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
years apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex47"/>
</element>
<!-- function result Visibility: default -->
@ -2754,6 +2778,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastMonths">
<short>Check whether two datetimes are only a number of months apart</short>
<descr>
<p>
<var>WithinPastMonths</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AMonths</var> months apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="MonthsBetween"/> function to calculate
the difference in Months, this means that fractional months do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
months apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex48"/>
</element>
<!-- function result Visibility: default -->
@ -2780,6 +2828,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastWeeks">
<short>Check whether two datetimes are only a number of weeks apart</short>
<descr>
<p>
<var>WithinPastWeeks</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AWeeks</var> weeks apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="WeeksBetween"/> function to calculate
the difference in Weeks, this means that fractional Weeks do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
weeks apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex49"/>
</element>
<!-- function result Visibility: default -->
@ -2806,6 +2878,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastDays">
<short>Check whether two datetimes are only a number of days apart</short>
<descr>
<p>
<var>WithinPastDays</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>ADays</var> days apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="DaysBetween"/> function to calculate
the difference in days, this means that fractional days do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
days apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex50"/>
</element>
<!-- function result Visibility: default -->
@ -2832,6 +2928,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastHours">
<short>Check whether two datetimes are only a number of hours apart</short>
<descr>
<p>
<var>WithinPastHours</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AHours</var> hours apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="HoursBetween"/> function to calculate
the difference in Hours, this means that fractional hours do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
hours apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex51"/>
</element>
<!-- function result Visibility: default -->
@ -2858,6 +2978,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastMinutes">
<short>Check whether two datetimes are only a number of minutes apart</short>
<descr>
<p>
<var>WithinPastMinutes</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AMinutes</var> minutes apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="MinutesBetween"/> function to calculate
the difference in Minutes, this means that fractional minutes do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
minutes apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastSeconds"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex52"/>
</element>
<!-- function result Visibility: default -->
@ -2884,6 +3028,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastSeconds">
<short>Check whether two datetimes are only a number of seconds apart</short>
<descr>
<p>
<var>WithinPastSeconds</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>ASeconds</var> seconds apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="SecondsBetween"/> function to calculate
the difference in seconds, this means that fractional seconds do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
seconds apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastMilliSeconds"/>
</seealso>
<example file="datutex/ex53"/>
</element>
<!-- function result Visibility: default -->
@ -2910,6 +3078,30 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WithinPastMilliSeconds">
<short>Check whether two datetimes are only a number of milliseconds apart</short>
<descr>
<p>
<var>WithinPastMilliSeconds</var> compares the timestamps <var>ANow</var> and <var>AThen</var>
and returns <var>True</var> if the difference between them is at most
<var>AMilliSeconds</var> milliseconds apart, or <var>False</var> if they are further
apart.
</p>
<remark>
Since this function uses the <link id="MilliSecondsBetween"/> function to calculate
the difference in milliseconds, this means that fractional milliseconds do not count, and
the fractional part is simply dropped, so for two dates actually 2 and a half
milliseconds apart, the result will also be <var>True</var>
</remark>
</descr>
<seealso>
<link id="WithinPastYears"/>
<link id="WithinPastMonths"/>
<link id="WithinPastWeeks"/>
<link id="WithinPastDays"/>
<link id="WithinPastHours"/>
<link id="WithinPastMinutes"/>
<link id="WithinPastSeconds"/>
</seealso>
<example file="datutex/ex54"/>
</element>
<!-- function result Visibility: default -->
@ -2936,6 +3128,22 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="YearsBetween">
<short>Calculate the number of whole years between two DateTime values</short>
<descr>
<var>YearsBetween</var> returns the number of whole years between
<var>ANow</var> and <var>AThen</var>. This number is an approximation,
based on an average number of days of 365.25 per year (average over 4
years). This means the fractional part of a year is dropped.
</descr>
<seealso>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex55"/>
</element>
<!-- function result Visibility: default -->
@ -2956,6 +3164,22 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="MonthsBetween">
<short>Calculate the number of whole months between two DateTime values</short>
<descr>
<var>MonthsBetween</var> returns the number of whole months between
<var>ANow</var> and <var>AThen</var>. This number is an approximation,
based on an average number of days of 30.4375 per month (average over 4
years). This means the fractional part of a month is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex56"/>
</element>
<!-- function result Visibility: default -->
@ -2976,6 +3200,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="WeeksBetween">
<short>Calculate the number of whole weeks between two DateTime values</short>
<descr>
<var>WeeksBetween</var> returns the number of whole weeks between
<var>ANow</var> and <var>AThen</var>.
This means the fractional part of a Week is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex57"/>
</element>
<!-- function result Visibility: default -->
@ -2996,6 +3235,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="DaysBetween">
<short>Number of whole days between two DateTime values.</short>
<descr>
<var>DaysBetween</var> returns the number of whole days between
<var>ANow</var> and <var>AThen</var>.
This means the fractional part of a day (hours, minutes, etc.) is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex58"/>
</element>
<!-- function result Visibility: default -->
@ -3016,6 +3270,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="HoursBetween">
<short>Calculate the number of whole hours between two DateTime values.</short>
<descr>
<var>HoursBetween</var> returns the number of whole hours between
<var>ANow</var> and <var>AThen</var>.
This means the fractional part of an hour (minutes,seconds etc.) is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex59"/>
</element>
<!-- function result Visibility: default -->
@ -3036,6 +3305,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="MinutesBetween">
<short>Calculate the number of whole minutes between two DateTime values.</short>
<descr>
<var>MinutesBetween</var> returns the number of whole minutes between
<var>ANow</var> and <var>AThen</var>.
This means the fractional part of a minute (seconds, milliseconds etc.) is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="SecondsBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex60"/>
</element>
<!-- function result Visibility: default -->
@ -3056,6 +3340,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="SecondsBetween">
<short>Calculate the number of whole seconds between two DateTime values.</short>
<descr>
<var>SecondsBetween</var> returns the number of whole seconds between
<var>ANow</var> and <var>AThen</var>.
This means the fractional part of a second (milliseconds etc.) is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="MilliSecondsBetween"/>
</seealso>
<example file="datutex/ex61"/>
</element>
<!-- function result Visibility: default -->
@ -3076,6 +3375,21 @@ HH:MM:SS.000 will return 0.
<!-- function Visibility: default -->
<element name="MilliSecondsBetween">
<short>Calculate the number of whole milliseconds between two DateTime values.</short>
<descr>
<var>MillisSecondsBetween</var> returns the number of whole milliseconds between
<var>ANow</var> and <var>AThen</var>.
This means a fractional part of a millisecond is dropped.
</descr>
<seealso>
<link id="YearsBetween"/>
<link id="MonthsBetween"/>
<link id="WeeksBetween"/>
<link id="DaysBetween"/>
<link id="HoursBetween"/>
<link id="MinutesBetween"/>
<link id="SecondsBetween"/>
</seealso>
<example file="datutex/ex62"/>
</element>
<!-- function result Visibility: default -->

View File

@ -43,3 +43,19 @@ ex43.pp contains examples of the PartOfTheDay functions.
ex44.pp contains examples of the PartOfTheHour functions.
ex45.pp contains examples of the PartOfTheMinute functions.
ex46.pp contains an example of the MilliSecondOfTheSecond functions.
ex47.pp contains an example of the WithinPastYears function.
ex48.pp contains an example of the WithinPastMonths function.
ex49.pp contains an example of the WithinPastWeeks function.
ex50.pp contains an example of the WithinPastDays function.
ex51.pp contains an example of the WithinPastHours function.
ex52.pp contains an example of the WithinPastMinutes function.
ex53.pp contains an example of the WithinPastSeconds function.
ex54.pp contains an example of the WithinPastMilliSeconds function.
ex55.pp contains an example of the YearsBetween function.
ex56.pp contains an example of the MonthsBetween function.
ex57.pp contains an example of the WeeksBetween function.
ex58.pp contains an example of the DaysBetween function.
ex59.pp contains an example of the HoursBetween function.
ex60.pp contains an example of the MinutesBetween function.
ex61.pp contains an example of the SecondsBetween function.
ex62.pp contains an example of the MilliSecondsBetween function.

34
docs/datutex/ex47.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example47;
{ This program demonstrates the WithinPastYears function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AYears : Integer);
begin
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Write(' are within ',AYears,' years: ');
Writeln(WithinPastYears(ANow,AThen,AYears));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-364;
Test(D1,D2,1);
D2:=Today-365;
Test(D1,D2,1);
D2:=Today-366;
Test(D1,D2,1);
D2:=Today-390;
Test(D1,D2,1);
D2:=Today-368;
Test(D1,D2,1);
D2:=Today-1000;
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

34
docs/datutex/ex48.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example48;
{ This program demonstrates the WithinPastMonths function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AMonths : Integer);
begin
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Write(' are within ',AMonths,' months: ');
Writeln(WithinPastMonths(ANow,AThen,AMonths));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-364;
Test(D1,D2,12);
D2:=Today-365;
Test(D1,D2,12);
D2:=Today-366;
Test(D1,D2,12);
D2:=Today-390;
Test(D1,D2,12);
D2:=Today-368;
Test(D1,D2,11);
D2:=Today-1000;
Test(D1,D2,31);
Test(D1,D2,32);
Test(D1,D2,33);
End.

34
docs/datutex/ex49.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example49;
{ This program demonstrates the WithinPastWeeks function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AWeeks : Integer);
begin
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Write(' are within ',AWeeks,' weeks: ');
Writeln(WithinPastWeeks(ANow,AThen,AWeeks));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-7;
Test(D1,D2,1);
D2:=Today-8;
Test(D1,D2,1);
D2:=Today-14;
Test(D1,D2,1);
D2:=Today-35;
Test(D1,D2,5);
D2:=Today-36;
Test(D1,D2,5);
D2:=Today-17;
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

34
docs/datutex/ex50.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example50;
{ This program demonstrates the WithinPastDays function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; ADays : Integer);
begin
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Write(' are within ',ADays,' days: ');
Writeln(WithinPastDays(ANow,AThen,ADays));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=Today-23/24;
Test(D1,D2,1);
D2:=Today-1;
Test(D1,D2,1);
D2:=Today-25/24;
Test(D1,D2,1);
D2:=Today-26/24;
Test(D1,D2,5);
D2:=Today-5.4;
Test(D1,D2,5);
D2:=Today-2.5;
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

34
docs/datutex/ex51.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example51;
{ This program demonstrates the WithinPastHours function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AHours : Integer);
begin
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Write(' are within ',AHours,' hours: ');
Writeln(WithinPastHours(ANow,AThen,AHours));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(59*OneMinute);
Test(D1,D2,1);
D2:=D1-(61*OneMinute);
Test(D1,D2,1);
D2:=D1-(122*OneMinute);
Test(D1,D2,1);
D2:=D1-(306*OneMinute);
Test(D1,D2,5);
D2:=D1-(5.4*OneHour);
Test(D1,D2,5);
D2:=D1-(2.5*OneHour);
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

34
docs/datutex/ex52.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example52;
{ This program demonstrates the WithinPastMinutes function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AMinutes : Integer);
begin
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Write(' are within ',AMinutes,' Minutes: ');
Writeln(WithinPastMinutes(ANow,AThen,AMinutes));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(59*OneSecond);
Test(D1,D2,1);
D2:=D1-(61*OneSecond);
Test(D1,D2,1);
D2:=D1-(122*OneSecond);
Test(D1,D2,1);
D2:=D1-(306*OneSecond);
Test(D1,D2,5);
D2:=D1-(5.4*OneMinute);
Test(D1,D2,5);
D2:=D1-(2.5*OneMinute);
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

34
docs/datutex/ex53.pp Normal file
View File

@ -0,0 +1,34 @@
Program Example53;
{ This program demonstrates the WithinPastSeconds function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; ASeconds : Integer);
begin
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Write(' are within ',ASeconds,' seconds: ');
Writeln(WithinPastSeconds(ANow,AThen,ASeconds));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(999*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(1001*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(2001*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(5001*OneMilliSecond);
Test(D1,D2,5);
D2:=D1-(5.4*OneSecond);
Test(D1,D2,5);
D2:=D1-(2.5*OneSecond);
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

30
docs/datutex/ex54.pp Normal file
View File

@ -0,0 +1,30 @@
Program Example54;
{ This program demonstrates the WithinPastMilliSeconds function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime; AMilliSeconds : Integer);
begin
Write(TimeToStr(AThen),' and ',TimeToStr(ANow));
Write(' are within ',AMilliSeconds,' milliseconds: ');
Writeln(WithinPastMilliSeconds(ANow,AThen,AMilliSeconds));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(0.9*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(1.0*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(1.1*OneMilliSecond);
Test(D1,D2,1);
D2:=D1-(2.5*OneMilliSecond);
Test(D1,D2,1);
Test(D1,D2,2);
Test(D1,D2,3);
End.

32
docs/datutex/ex55.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example55;
{ This program demonstrates the YearsBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of years between ');
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Writeln(' : ',YearsBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-364;
Test(D1,D2);
D2:=Today-365;
Test(D1,D2);
D2:=Today-366;
Test(D1,D2);
D2:=Today-390;
Test(D1,D2);
D2:=Today-368;
Test(D1,D2);
D2:=Today-1000;
Test(D1,D2);
End.

32
docs/datutex/ex56.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example56;
{ This program demonstrates the WithinPastMonths function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of months between ');
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Writeln(' : ',MonthsBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-364;
Test(D1,D2);
D2:=Today-365;
Test(D1,D2);
D2:=Today-366;
Test(D1,D2);
D2:=Today-390;
Test(D1,D2);
D2:=Today-368;
Test(D1,D2);
D2:=Today-1000;
Test(D1,D2);
End.

32
docs/datutex/ex57.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example57;
{ This program demonstrates the WeeksBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of weeks between ');
Write(DateToStr(AThen),' and ',DateToStr(ANow));
Writeln(' : ',WeeksBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Today;
D2:=Today-7;
Test(D1,D2);
D2:=Today-8;
Test(D1,D2);
D2:=Today-14;
Test(D1,D2);
D2:=Today-35;
Test(D1,D2);
D2:=Today-36;
Test(D1,D2);
D2:=Today-17;
Test(D1,D2);
End.

32
docs/datutex/ex58.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example58;
{ This program demonstrates the DaysBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of days between ');
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Writeln(' : ',DaysBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=Today-23/24;
Test(D1,D2);
D2:=Today-1;
Test(D1,D2);
D2:=Today-25/24;
Test(D1,D2);
D2:=Today-26/24;
Test(D1,D2);
D2:=Today-5.4;
Test(D1,D2);
D2:=Today-2.5;
Test(D1,D2);
End.

32
docs/datutex/ex59.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example59;
{ This program demonstrates the HoursBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of hours between ');
Write(DateTimeToStr(AThen),' and ',DateTimeToStr(ANow));
Writeln(' : ',HoursBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(59*OneMinute);
Test(D1,D2);
D2:=D1-(61*OneMinute);
Test(D1,D2);
D2:=D1-(122*OneMinute);
Test(D1,D2);
D2:=D1-(306*OneMinute);
Test(D1,D2);
D2:=D1-(5.4*OneHour);
Test(D1,D2);
D2:=D1-(2.5*OneHour);
Test(D1,D2);
End.

32
docs/datutex/ex60.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example60;
{ This program demonstrates the MinutesBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of minutes between ');
Write(TimeToStr(AThen),' and ',TimeToStr(ANow));
Writeln(' : ',MinutesBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(59*OneSecond);
Test(D1,D2);
D2:=D1-(61*OneSecond);
Test(D1,D2);
D2:=D1-(122*OneSecond);
Test(D1,D2);
D2:=D1-(306*OneSecond);
Test(D1,D2);
D2:=D1-(5.4*OneMinute);
Test(D1,D2);
D2:=D1-(2.5*OneMinute);
Test(D1,D2);
End.

32
docs/datutex/ex61.pp Normal file
View File

@ -0,0 +1,32 @@
Program Example61;
{ This program demonstrates the SecondsBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of seconds between ');
Write(TimeToStr(AThen),' and ',TimeToStr(ANow));
Writeln(' : ',SecondsBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(999*OneMilliSecond);
Test(D1,D2);
D2:=D1-(1001*OneMilliSecond);
Test(D1,D2);
D2:=D1-(2001*OneMilliSecond);
Test(D1,D2);
D2:=D1-(5001*OneMilliSecond);
Test(D1,D2);
D2:=D1-(5.4*OneSecond);
Test(D1,D2);
D2:=D1-(2.5*OneSecond);
Test(D1,D2);
End.

28
docs/datutex/ex62.pp Normal file
View File

@ -0,0 +1,28 @@
Program Example62;
{ This program demonstrates the MilliSecondsBetween function }
Uses SysUtils,DateUtils;
Procedure Test(ANow,AThen : TDateTime);
begin
Write('Number of milliseconds between ');
Write(TimeToStr(AThen),' and ',TimeToStr(ANow));
Writeln(' : ',MilliSecondsBetween(ANow,AThen));
end;
Var
D1,D2 : TDateTime;
Begin
D1:=Now;
D2:=D1-(0.9*OneMilliSecond);
Test(D1,D2);
D2:=D1-(1.0*OneMilliSecond);
Test(D1,D2);
D2:=D1-(1.1*OneMilliSecond);
Test(D1,D2);
D2:=D1-(2.5*OneMilliSecond);
Test(D1,D2);
End.