extpas.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2015 by Florian Klaempfl
  4. This unit contain procedures specific for an extended pascal compatible mode.
  5. It should be platform independent.
  6. See the file COPYING.FPC, included in this distribution,
  7. For details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit extpas;
  13. interface
  14. type
  15. TimeStamp = packed record
  16. DateValid : Boolean;
  17. TimeValid : Boolean;
  18. year : Integer;
  19. month : 1..12;
  20. day : 1..31;
  21. hour : 0..23;
  22. minute : 0..59;
  23. second : 0..59;
  24. { implementation specific }
  25. second100 : 0..99;
  26. end;
  27. procedure GetTimeStamp(var ts : TimeStamp);
  28. implementation
  29. uses
  30. dos;
  31. procedure GetTimeStamp(var ts : TimeStamp);
  32. var
  33. year1,month1,mday1,wday1,
  34. year2,month2,mday2,wday2,
  35. hour,minute,second,sec100 : word;
  36. begin
  37. repeat
  38. GetDate(year1,month1,mday1,wday1);
  39. GetTime(hour,minute,second,sec100);
  40. GetDate(year2,month2,mday2,wday2);
  41. { the date may not have changed while we read the time }
  42. until (year1=year2) and (month1=month2) and (mday1=mday2);
  43. ts.DateValid:=true;
  44. ts.TimeValid:=true;
  45. ts.year:=year1;
  46. ts.month:=month1;
  47. ts.day:=mday1;
  48. ts.hour:=hour;
  49. ts.minute:=minute;
  50. ts.second:=second;
  51. ts.second100:=sec100;
  52. end;
  53. end.