ex106.pp 454 B

12345678910111213141516171819
  1. Program Example105;
  2. { This program demonstrates the DecodeDayOfWeekInMonth function }
  3. Uses SysUtils,DateUtils;
  4. Var
  5. Y,M,NDoW,DoW : Word;
  6. D : TDateTime;
  7. Begin
  8. DecodeDayOfWeekInMonth(Date,Y,M,NDoW,DoW);
  9. If TryEncodeDayOfWeekInMonth(Y,M,NDoW,DoW,D) then
  10. begin
  11. Write(DateToStr(D),' is the ',NDow,'-th ');
  12. Writeln(formatdateTime('dddd',D),' of the month.');
  13. end
  14. else
  15. Writeln('Invalid year/month/NthDayOfweek combination');
  16. End.