extpas.pp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. {$IFDEF FPC_DOTTEDUNITS}
  30. uses
  31. TP.DOS;
  32. {$ELSE}
  33. uses
  34. dos;
  35. {$ENDIF}
  36. procedure GetTimeStamp(var ts : TimeStamp);
  37. var
  38. year1,month1,mday1,wday1,
  39. year2,month2,mday2,wday2,
  40. hour,minute,second,sec100 : word;
  41. begin
  42. repeat
  43. GetDate(year1,month1,mday1,wday1);
  44. GetTime(hour,minute,second,sec100);
  45. GetDate(year2,month2,mday2,wday2);
  46. { the date may not have changed while we read the time }
  47. until (year1=year2) and (month1=month2) and (mday1=mday2);
  48. ts.DateValid:=true;
  49. ts.TimeValid:=true;
  50. ts.year:=year1;
  51. ts.month:=month1;
  52. ts.day:=mday1;
  53. ts.hour:=hour;
  54. ts.minute:=minute;
  55. ts.second:=second;
  56. ts.second100:=sec100;
  57. end;
  58. end.