datih.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. *********************************************************************
  3. $Id$
  4. Copyright (C) 1997, 1998 Gertjan Schouten
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. *********************************************************************
  17. System Utilities For Free Pascal
  18. }
  19. const
  20. SecsPerDay = 24 * 60 * 60; // Seconds and milliseconds per day
  21. MSecsPerDay = SecsPerDay * 1000;
  22. DateDelta = 693594; // Days between 1/1/0001 and 12/31/1899
  23. TwoDigitYearCenturyWindow : word=0;
  24. { Threshold to be subtracted from year before
  25. age-detection.}
  26. { date time formatting characters:
  27. c : shortdateformat + ' ' + shorttimeformat
  28. d : day of month
  29. dd : day of month (leading zero)
  30. ddd : day of week (abbreviation)
  31. dddd : day of week (full)
  32. ddddd : shortdateformat
  33. dddddd : longdateformat
  34. m : month
  35. mm : month (leading zero)
  36. mmm : month (abbreviation)
  37. mmmm : month (full)
  38. y : year (four digits)
  39. yy : year (two digits)
  40. yyyy : year (with century)
  41. h : hour
  42. hh : hour (leading zero)
  43. n : minute
  44. nn : minute (leading zero)
  45. s : second
  46. ss : second (leading zero)
  47. t : shorttimeformat
  48. tt : longtimeformat
  49. am/pm : use 12 hour clock and display am and pm accordingly
  50. a/p : use 12 hour clock and display a and p accordingly
  51. / : insert date seperator
  52. : : insert time seperator
  53. "xx" : literal text
  54. 'xx' : literal text
  55. }
  56. type
  57. TSystemTime = record
  58. Year, Month, Day: word;
  59. Hour, Minute, Second, MilliSecond: word;
  60. end ;
  61. TTimeStamp = record
  62. Time: integer; { Number of milliseconds since midnight }
  63. Date: integer; { One plus number of days since 1/1/0001 }
  64. end ;
  65. function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
  66. function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;
  67. function MSecsToTimeStamp(MSecs: Comp): TTimeStamp;
  68. function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
  69. function EncodeDate(Year, Month, Day :word): TDateTime;
  70. function EncodeTime(Hour, Minute, Second, MilliSecond:word): TDateTime;
  71. procedure DecodeDate(Date: TDateTime; var Year, Month, Day: word);
  72. procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
  73. procedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);
  74. function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
  75. function DayOfWeek(DateTime: TDateTime): integer;
  76. function Date: TDateTime;
  77. function Time: TDateTime;
  78. function Now: TDateTime;
  79. function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer): TDateTime;
  80. function IsLeapYear(Year: Word): boolean;
  81. function DateToStr(Date: TDateTime): string;
  82. function TimeToStr(Time: TDateTime): string;
  83. function DateTimeToStr(DateTime: TDateTime): string;
  84. function StrToDate(const S: string): TDateTime;
  85. function StrToTime(const S: string): TDateTime;
  86. function StrToDateTime(const S: string): TDateTime;
  87. function FormatDateTime(FormatStr: string; DateTime: TDateTime):string;
  88. procedure DateTimeToString(var Result: string; const FormatStr: string; const DateTime: TDateTime);
  89. Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
  90. Function FileDateToDateTime (Filedate : Longint) :TDateTime;
  91. { FPC Extra }
  92. Procedure GetLocalTime(var SystemTime: TSystemTime);
  93. {
  94. $Log$
  95. Revision 1.4 2001-11-14 23:00:17 michael
  96. + First working variant support
  97. Revision 1.3 2000/08/20 15:46:46 peter
  98. * sysutils.pp moved to target and merged with disk.inc, filutil.inc
  99. }