datih.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. DateSeparator:char='-';
  24. TimeSeparator:char=':';
  25. TimeAMString: pchar = 'am';
  26. TimePMString: pchar = 'pm';
  27. ShortMonthNames: array[1..12] of pchar =
  28. ('jan','feb','mar','apr','mai','jun',
  29. 'jul','aug','sep','oct','nov','dec');
  30. LongMonthNames: array[1..12] of pchar=
  31. ('january','february','march','april','mai','june',
  32. 'july','august','september','october','november','december');
  33. ShortDayNames: array[1..7] of pchar=
  34. ('sun','mon','tue','wen','thu','fri','sat');
  35. LongDayNames: array[1..7] of pchar=
  36. ('sunday','monday','tuesday','wednesday','thursday','friday','saturday');
  37. { date time formatting characters:
  38. c : shortdateformat + ' ' + shorttimeformat
  39. d : day of month
  40. dd : day of month (leading zero)
  41. ddd : day of week (abbreviation)
  42. dddd : day of week (full)
  43. ddddd : shortdateformat
  44. dddddd : longdateformat
  45. m : month
  46. mm : month (leading zero)
  47. mmm : month (abbreviation)
  48. mmmm : month (full)
  49. y : year (four digits)
  50. yy : year (two digits)
  51. yyyy : year (with century)
  52. h : hour
  53. hh : hour (leading zero)
  54. n : minute
  55. nn : minute (leading zero)
  56. s : second
  57. ss : second (leading zero)
  58. t : shorttimeformat
  59. tt : longtimeformat
  60. am/pm : use 12 hour clock and display am and pm accordingly
  61. a/p : use 12 hour clock and display a and p accordingly
  62. / : insert date seperator
  63. : : insert time seperator
  64. "xx" : literal text
  65. 'xx' : literal text
  66. }
  67. // these constant strings will be changed to pchars too, someday :)
  68. ShortDateFormat:string='d/m/y';
  69. LongDateFormat:string='dd" "mmmm" "yyyy';
  70. ShortTimeFormat:string='hh:nn';
  71. LongTimeFormat:string='hh:nn:ss';
  72. Eoln = #10; // or should that be #13, or $0d0a
  73. type
  74. TSystemTime=record
  75. wYear:word;wMonth:word;wDay:word;
  76. wHour:word;wMinute:word;wSecond:word;wMilliSecond:word;
  77. end ;
  78. TDateTime = double;
  79. { Date and Time functions }
  80. function DateToStr(Date:TDateTime):string;
  81. function TimeToStr(Time:TDateTime):string;
  82. function DateTimeToStr(DateTime:TDateTime):string;
  83. function EncodeDate(Year, Month, Day :word):TDateTime;
  84. function EncodeTime(Hour, Minute, Second, MilliSecond:word):TDateTime;
  85. procedure DecodeDate(Date:TDateTime;var Year:word;var Month:word;var Day:word);
  86. procedure DecodeTime(Time:TDateTime;var Hour:word;var Minute:word;var Second:word;var MilliSecond:word);
  87. function FormatDateTime(FormatStr:string;DateTime:TDateTime):string;
  88. function StrToDate(const s:string):TDateTime;
  89. function StrToTime(const s:string):TDateTime;
  90. function StrToDateTime(const s:string):TDateTime;
  91. function DayOfWeek(DateTime:TDateTime):longint;
  92. function Date:TDateTime;
  93. function Time:TDateTime;
  94. function Now:TDateTime;
  95. procedure GetLocalTime(var systemtime:tsystemtime);
  96. {
  97. $Log$
  98. Revision 1.1 1998-04-10 15:17:46 michael
  99. + Initial implementation; Donated by Gertjan Schouten
  100. His file was split into several files, to keep it a little bit structured.
  101. }