dati.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. {==============================================================================}
  20. { internal functions }
  21. {==============================================================================}
  22. const
  23. DayTable: array[Boolean, 1..12] of longint =
  24. ((0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
  25. (0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335));
  26. function DoEncodeDate(Year, Month, Day: Word): longint;
  27. var
  28. c, ya: cardinal;
  29. begin
  30. if (Month > 0) and (Month < 13) and (Day > 0) and (Day < 32) then
  31. begin
  32. if month > 2 then
  33. Dec(Month,3)
  34. else
  35. begin
  36. Inc(Month,9);
  37. Dec(Year);
  38. end;
  39. c:= Year DIV 100;
  40. ya:= Year - 100*c;
  41. result := (146097*c) SHR 2 + (1461*ya) SHR 2 + (153*cardinal(Month)+2) DIV 5 + cardinal(Day) - 693900;
  42. end
  43. else
  44. result:=0;
  45. end;
  46. function DoEncodeTime(Hour, Minute, Second, MilliSecond: word): longint;
  47. begin
  48. If ((hour>=0) and (Hour<24)) and
  49. ((Minute>=0) and (Minute<60)) and
  50. ((Second>=0) and (Second<60)) and
  51. ((MilliSecond>=0) and (Millisecond<1000)) then
  52. Result := (Hour * 3600000 + Minute * 60000 + Second * 1000 + MilliSecond)
  53. else
  54. Result:=0;
  55. end;
  56. {==============================================================================}
  57. { Public functions }
  58. {==============================================================================}
  59. { DateTimeToTimeStamp converts DateTime to a TTimeStamp }
  60. function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
  61. begin
  62. result.Time := Trunc(Frac(DateTime) * MSecsPerDay);
  63. result.Date := 1 + DateDelta + Trunc(System.Int(DateTime));
  64. end ;
  65. { TimeStampToDateTime converts TimeStamp to a TDateTime value }
  66. function TimeStampToDateTime(const TimeStamp: TTimeStamp): TDateTime;
  67. begin
  68. result := (TimeStamp.Date - DateDelta - 1) + (TimeStamp.Time / MSecsPerDay);
  69. end ;
  70. { MSecsToTimeStamp }
  71. function MSecsToTimeStamp(MSecs: comp): TTimeStamp;
  72. begin
  73. result.Date := Round(msecs / msecsperday);
  74. msecs:= comp(msecs-result.date*msecsperday);
  75. result.Time := Round(MSecs);
  76. end ;
  77. { TimeStampToMSecs }
  78. function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;
  79. begin
  80. result := TimeStamp.Time + timestamp.date*msecsperday;
  81. end ;
  82. { EncodeDate packs three variables Year, Month and Day into a
  83. TDateTime value the result is the number of days since 12/30/1899 }
  84. function EncodeDate(Year, Month, Day: word): TDateTime;
  85. begin
  86. result := DoEncodeDate(Year, Month, Day);
  87. end ;
  88. { EncodeTime packs four variables Hour, Minute, Second and MilliSecond into
  89. a TDateTime value }
  90. function EncodeTime(Hour, Minute, Second, MilliSecond:word):TDateTime;
  91. begin
  92. Result := DoEncodeTime(hour, minute, second, millisecond) / MSecsPerDay;
  93. end ;
  94. { DecodeDate unpacks the value Date into three values:
  95. Year, Month and Day }
  96. procedure DecodeDate(Date: TDateTime; var Year, Month, Day: word);
  97. var
  98. j : cardinal;
  99. begin
  100. j := pred((Trunc(System.Int(Date)) + 693900) SHL 2);
  101. Year:= j DIV 146097;
  102. j:= j - 146097 * cardinal(Year);
  103. Day := j SHR 2;
  104. j:=(Day SHL 2 + 3) DIV 1461;
  105. Day:= (cardinal(Day) SHL 2 + 7 - 1461*j) SHR 2;
  106. Month:=(5 * Day-3) DIV 153;
  107. Day:= (5 * Day +2 - 153*Month) DIV 5;
  108. Year:= 100 * cardinal(Year) + j;
  109. if Month < 10 then
  110. inc(Month,3)
  111. else
  112. begin
  113. dec(Month,9);
  114. inc(Year);
  115. end;
  116. end;
  117. { DecodeTime unpacks Time into four values:
  118. Hour, Minute, Second and MilliSecond }
  119. procedure DecodeTime(Time: TDateTime; var Hour, Minute, Second, MilliSecond: word);
  120. Var
  121. l : cardinal;
  122. begin
  123. l := Round(Frac(time) * MSecsPerDay);
  124. Hour := l div 3600000;
  125. l := l mod 3600000;
  126. Minute := l div 60000;
  127. l := l mod 60000;
  128. Second := l div 1000;
  129. l := l mod 1000;
  130. MilliSecond := l;
  131. end;
  132. { DateTimeToSystemTime converts DateTime value to SystemTime }
  133. procedure DateTimeToSystemTime(DateTime: TDateTime; var SystemTime: TSystemTime);
  134. begin
  135. DecodeDate(DateTime, SystemTime.Year, SystemTime.Month, SystemTime.Day);
  136. DecodeTime(DateTime, SystemTime.Hour, SystemTime.Minute, SystemTime.Second, SystemTime.MilliSecond);
  137. end ;
  138. { SystemTimeToDateTime converts SystemTime to a TDateTime value }
  139. function SystemTimeToDateTime(const SystemTime: TSystemTime): TDateTime;
  140. begin
  141. result := DoEncodeDate(SystemTime.Year, SystemTime.Month, SystemTime.Day) +
  142. DoEncodeTime(SystemTime.Hour, SystemTime.Minute, SystemTime.Second, SystemTime.MilliSecond) / MSecsPerDay;
  143. end ;
  144. { DayOfWeek returns the Day of the week (sunday is day 1) }
  145. function DayOfWeek(DateTime: TDateTime): integer;
  146. begin
  147. Result := 1 + (Abs(Trunc(DateTime) - 1) mod 7);
  148. end ;
  149. { Date returns the current Date }
  150. function Date: TDateTime;
  151. var
  152. SystemTime: TSystemTime;
  153. begin
  154. GetLocalTime(SystemTime);
  155. result := DoEncodeDate(SystemTime.Year, SystemTime.Month, SystemTime.Day);
  156. end ;
  157. { Time returns the current Time }
  158. function Time: TDateTime;
  159. var
  160. SystemTime: TSystemTime;
  161. begin
  162. GetLocalTime(SystemTime);
  163. Result := DoEncodeTime(SystemTime.Hour,SystemTime.Minute,SystemTime.Second,SystemTime.MilliSecond) / MSecsPerDay;
  164. end ;
  165. { Now returns the current Date and Time }
  166. function Now: TDateTime;
  167. var
  168. SystemTime: TSystemTime;
  169. begin
  170. GetLocalTime(SystemTime);
  171. result := DoEncodeDate(SystemTime.Year,SystemTime.Month,SystemTime.Day) +
  172. DoEncodeTime(SystemTime.Hour,SystemTime.Minute,SystemTime.Second,SystemTime.MilliSecond) / MSecsPerDay;
  173. end ;
  174. { IncMonth increments DateTime with NumberOfMonths months,
  175. NumberOfMonths can be less than zero }
  176. function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer): TDateTime;
  177. var
  178. Year, Month, Day: word;
  179. S : Integer;
  180. begin
  181. If NumberOfMonths>=0 then
  182. s:=1
  183. else
  184. s:=-1;
  185. DecodeDate(DateTime, Year, Month, Day);
  186. inc(Year,(NumberOfMonths div 12));
  187. inc(Month,(NumberOfMonths mod 12)-1); // Mod result always positive
  188. if Month>11 then
  189. begin
  190. Dec(Month, S*12);
  191. Inc(Year, S);
  192. end;
  193. Inc(Month); { Months from 1 to 12 }
  194. if (Month = 2) and (IsLeapYear(Year)) and (Day > 28) then
  195. Day := 28;
  196. result := Frac(DateTime) + DoEncodeDate(Year, Month, Day);
  197. end ;
  198. { IsLeapYear returns true if Year is a leap year }
  199. function IsLeapYear(Year: Word): boolean;
  200. begin
  201. Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));
  202. end;
  203. { DateToStr returns a string representation of Date using ShortDateFormat }
  204. function DateToStr(Date: TDateTime): string;
  205. begin
  206. result := FormatDateTime('ddddd', Date);
  207. end ;
  208. { TimeToStr returns a string representation of Time using ShortTimeFormat }
  209. function TimeToStr(Time: TDateTime): string;
  210. begin
  211. result := FormatDateTime('t', Time);
  212. end ;
  213. { DateTimeToStr returns a string representation of DateTime using ShortDateTimeFormat }
  214. function DateTimeToStr(DateTime: TDateTime): string;
  215. begin
  216. result := FormatDateTime('c', DateTime);
  217. end ;
  218. { StrToDate converts the string S to a TDateTime value
  219. if S does not represent a valid date value
  220. an EConvertError will be raised }
  221. function StrToDate(const S: string): TDateTime;
  222. var
  223. df:string;
  224. d,m,y:word;
  225. n,i:longint;
  226. c:word;
  227. dp,mp,yp,which : Byte;
  228. s1:string[4];
  229. values:array[1..3] of longint;
  230. LocalTime:tsystemtime;
  231. begin
  232. df := UpperCase(ShortDateFormat);
  233. { Determine order of D,M,Y }
  234. yp:=0;
  235. mp:=0;
  236. dp:=0;
  237. Which:=0;
  238. i:=0;
  239. while (i<Length(df)) and (Which<3) do
  240. begin
  241. inc(i);
  242. Case df[i] of
  243. 'Y' :
  244. if yp=0 then
  245. begin
  246. Inc(Which);
  247. yp:=which;
  248. end;
  249. 'M' :
  250. if mp=0 then
  251. begin
  252. Inc(Which);
  253. mp:=which;
  254. end;
  255. 'D' :
  256. if dp=0 then
  257. begin
  258. Inc(Which);
  259. dp:=which;
  260. end;
  261. end;
  262. end;
  263. if Which<>3 then
  264. Raise EConvertError.Create('Illegal format string');
  265. { Get actual values }
  266. for i := 1 to 3 do
  267. values[i] := 0;
  268. s1 := '';
  269. n := 0;
  270. for i := 1 to length(s) do
  271. begin
  272. if (s[i] in ['0'..'9']) then
  273. s1 := s1 + s[i];
  274. if (s[i] in [dateseparator,' ']) or (i = length(s)) then
  275. begin
  276. inc(n);
  277. if n>3 then
  278. Raise EConvertError.Create('Invalid date format');
  279. val(s1, values[n], c);
  280. if c<>0 then
  281. Raise EConvertError.Create('Invalid date format');
  282. s1 := '';
  283. end ;
  284. end ;
  285. // Fill in values.
  286. If N=3 then
  287. begin
  288. y:=values[yp];
  289. m:=values[mp];
  290. d:=values[dp];
  291. end
  292. Else
  293. begin
  294. getLocalTime(LocalTime);
  295. y := LocalTime.Year;
  296. If n<2 then
  297. begin
  298. d:=values[1];
  299. m := LocalTime.Month;
  300. end
  301. else
  302. If dp<mp then
  303. begin
  304. d:=values[1];
  305. m:=values[2];
  306. end
  307. else
  308. begin
  309. d:=values[2];
  310. m:=values[1];
  311. end;
  312. end;
  313. if (y >= 0) and (y < 100) then
  314. inc(y,1900);
  315. Result := DoEncodeDate(y, m, d);
  316. end ;
  317. { StrToTime converts the string S to a TDateTime value
  318. if S does not represent a valid time value an
  319. EConvertError will be raised }
  320. function StrToTime(const s: string): TDateTime;
  321. var
  322. Len, Current: integer; PM: boolean;
  323. function GetElement: integer;
  324. var
  325. j: integer; c: word;
  326. begin
  327. result := -1;
  328. Inc(Current);
  329. while (result = -1) and (Current < Len) do begin
  330. if S[Current] in ['0'..'9'] then begin
  331. j := Current;
  332. while (Current < Len) and (s[Current + 1] in ['0'..'9']) do
  333. Inc(Current);
  334. val(copy(S, j, 1 + Current - j), result, c);
  335. end
  336. else if (S[Current] = TimeAMString[1]) or (S[Current] in ['a', 'A']) then begin
  337. Current := 1 + Len;
  338. end
  339. else if (S[Current] = TimePMString[1]) or (S[Current] in ['p', 'P']) then begin
  340. Current := 1 + Len;
  341. PM := True;
  342. end
  343. else if (S[Current] = TimeSeparator) or (S[Current] = ' ') then
  344. Inc(Current)
  345. else
  346. raise EConvertError.Create('Invalid Time format');
  347. end ;
  348. end ;
  349. var
  350. i: integer;
  351. TimeValues: array[0..4] of integer;
  352. begin
  353. Current := 0;
  354. Len := length(s);
  355. PM := False;
  356. for i:=0 to 4 do
  357. timevalues[i]:=0;
  358. i := 0;
  359. TimeValues[i] := GetElement;
  360. while (i < 5) and (TimeValues[i] <> -1) do begin
  361. i := i + 1;
  362. TimeValues[i] := GetElement;
  363. end ;
  364. If (i<5) and (TimeValues[I]=-1) then
  365. TimeValues[I]:=0;
  366. if PM then Inc(TimeValues[0], 12);
  367. result := EncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3]);
  368. end ;
  369. { StrToDateTime converts the string S to a TDateTime value
  370. if S does not represent a valid date and time value
  371. an EConvertError will be raised }
  372. function StrToDateTime(const s: string): TDateTime;
  373. var i: integer;
  374. begin
  375. i := pos(' ', s);
  376. if i > 0 then result := StrToDate(Copy(S, 1, i - 1)) + StrToTime(Copy(S, i + 1, length(S)))
  377. else result := StrToDate(S);
  378. end ;
  379. { FormatDateTime formats DateTime to the given format string FormatStr }
  380. function FormatDateTime(FormatStr: string; DateTime: TDateTime): string;
  381. var
  382. ResultLen: integer;
  383. ResultBuffer: array[0..255] of char;
  384. ResultCurrent: pchar;
  385. procedure StoreStr(Str: pchar; Len: integer);
  386. begin
  387. if ResultLen + Len < SizeOf(ResultBuffer) then begin
  388. StrMove(ResultCurrent, Str, Len);
  389. ResultCurrent := ResultCurrent + Len;
  390. ResultLen := ResultLen + Len;
  391. end ;
  392. end ;
  393. procedure StoreString(const Str: string);
  394. var Len: integer;
  395. begin
  396. Len := Length(Str);
  397. if ResultLen + Len < SizeOf(ResultBuffer) then begin
  398. StrMove(ResultCurrent, pchar(Str), Len);
  399. ResultCurrent := ResultCurrent + Len;
  400. ResultLen := ResultLen + Len;
  401. end;
  402. end;
  403. procedure StoreInt(Value, Digits: integer);
  404. var S: string; Len: integer;
  405. begin
  406. S := IntToStr(Value);
  407. Len := Length(S);
  408. if Len < Digits then begin
  409. S := copy('0000', 1, Digits - Len) + S;
  410. Len := Digits;
  411. end ;
  412. StoreStr(pchar(@S[1]), Len);
  413. end ;
  414. Function TimeReFormat(Const S : string) : string;
  415. // Change m into n for time formatting.
  416. Var i : longint;
  417. begin
  418. Result:=S;
  419. For I:=1 to Length(Result) do
  420. If Result[i]='m' then
  421. result[i]:='n';
  422. end;
  423. var
  424. Year, Month, Day, DayOfWeek, Hour, Minute, Second, MilliSecond: word;
  425. procedure StoreFormat(const FormatStr: string);
  426. var
  427. Token: char;
  428. FormatCurrent: pchar;
  429. FormatEnd: pchar;
  430. Count: integer;
  431. Clock12: boolean;
  432. P: pchar;
  433. begin
  434. FormatCurrent := Pchar(FormatStr);
  435. FormatEnd := FormatCurrent + Length(FormatStr);
  436. Clock12 := false;
  437. P := FormatCurrent;
  438. while P < FormatEnd do begin
  439. Token := UpCase(P^);
  440. if Token in ['"', ''''] then begin
  441. P := P + 1;
  442. while (P < FormatEnd) and (P^ <> Token) do
  443. P := P + 1;
  444. end
  445. else if Token = 'A' then begin
  446. if (StrLIComp(P, 'A/P', 3) = 0) or
  447. (StrLIComp(P, 'AMPM', 4) = 0) or
  448. (StrLIComp(P, 'AM/PM', 5) = 0) then begin
  449. Clock12 := true;
  450. break;
  451. end ;
  452. end ;
  453. P := P + 1;
  454. end ;
  455. while FormatCurrent < FormatEnd do begin
  456. Token := UpCase(FormatCurrent^);
  457. Count := 1;
  458. P := FormatCurrent + 1;
  459. case Token of
  460. '''', '"': begin
  461. while (P < FormatEnd) and (p^ <> Token) do
  462. P := P + 1;
  463. P := P + 1;
  464. Count := P - FormatCurrent;
  465. StoreStr(FormatCurrent + 1, Count - 2);
  466. end ;
  467. 'A': begin
  468. if StrLIComp(FormatCurrent, 'AMPM', 4) = 0 then begin
  469. Count := 4;
  470. if Hour < 12 then StoreString(TimeAMString)
  471. else StoreString(TimePMString);
  472. end
  473. else if StrLIComp(FormatCurrent, 'AM/PM', 5) = 0 then begin
  474. Count := 5;
  475. if Hour < 12 then StoreStr('am', 2)
  476. else StoreStr('pm', 2);
  477. end
  478. else if StrLIComp(FormatCurrent, 'A/P', 3) = 0 then begin
  479. Count := 3;
  480. if Hour < 12 then StoreStr('a', 1)
  481. else StoreStr('p', 1);
  482. end
  483. else
  484. Raise EConvertError.Create('Illegal character in format string');
  485. end ;
  486. '/': StoreStr(@DateSeparator, 1);
  487. ':': StoreStr(@TimeSeparator, 1);
  488. ' ', 'C', 'D', 'H', 'M', 'N', 'S', 'T', 'Y': begin
  489. while (P < FormatEnd) and (UpCase(P^) = Token) do
  490. P := P + 1;
  491. Count := P - FormatCurrent;
  492. case Token of
  493. ' ': StoreStr(FormatCurrent, Count);
  494. 'Y': begin
  495. case Count of
  496. 1: StoreInt(Year, 0);
  497. 2: StoreInt(Year mod 100, 2);
  498. 4: StoreInt(Year, 4);
  499. end ;
  500. end ;
  501. 'M': begin
  502. case Count of
  503. 1: StoreInt(Month, 0);
  504. 2: StoreInt(Month, 2);
  505. 3: StoreString(ShortMonthNames[Month]);
  506. 4: StoreString(LongMonthNames[Month]);
  507. end ;
  508. end ;
  509. 'D': begin
  510. case Count of
  511. 1: StoreInt(Day, 0);
  512. 2: StoreInt(Day, 2);
  513. 3: StoreString(ShortDayNames[DayOfWeek]);
  514. 4: StoreString(LongDayNames[DayOfWeek]);
  515. 5: StoreFormat(ShortDateFormat);
  516. 6: StoreFormat(LongDateFormat);
  517. end ;
  518. end ;
  519. 'H': begin
  520. if Clock12 then begin
  521. if Count = 1 then StoreInt(Hour mod 12, 0)
  522. else StoreInt(Hour mod 12, 2);
  523. end
  524. else begin
  525. if Count = 1 then StoreInt(Hour, 0)
  526. else StoreInt(Hour, 2);
  527. end ;
  528. end ;
  529. 'N': begin
  530. if Count = 1 then StoreInt(Minute, 0)
  531. else StoreInt(Minute, 2);
  532. end ;
  533. 'S': begin
  534. if Count = 1 then StoreInt(Second, 0)
  535. else StoreInt(Second, 2);
  536. end ;
  537. 'T': begin
  538. if Count = 1 then StoreFormat(timereformat(ShortTimeFormat))
  539. else StoreFormat(TimeReformat(LongTimeFormat));
  540. end ;
  541. 'C':
  542. begin
  543. StoreFormat(ShortDateFormat);
  544. if (Hour<>0) or (Minute<>0) or (Second<>0) then
  545. begin
  546. StoreString(' ');
  547. StoreFormat(TimeReformat(ShortTimeFormat));
  548. end;
  549. end;
  550. end ;
  551. end ;
  552. else
  553. StoreStr(@Token, 1);
  554. end ;
  555. FormatCurrent := FormatCurrent + Count;
  556. end ;
  557. end ;
  558. begin
  559. DecodeDate(DateTime, Year, Month, Day);
  560. DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
  561. DayOfWeek := SysUtils.DayOfWeek(DateTime);
  562. ResultLen := 0;
  563. ResultCurrent := @ResultBuffer;
  564. StoreFormat(FormatStr);
  565. ResultBuffer[ResultLen] := #0;
  566. result := StrPas(@ResultBuffer);
  567. end ;
  568. { DateTimeToString formats DateTime to the given format in FormatStr }
  569. procedure DateTimeToString(var Result: string; const FormatStr: string; const DateTime: TDateTime);
  570. begin
  571. Result := FormatDateTime(FormatStr, DateTime);
  572. end ;
  573. Function DateTimeToFileDate(DateTime : TDateTime) : Longint;
  574. Var YY,MM,DD,H,m,s,msec : Word;
  575. begin
  576. Decodedate (DateTime,YY,MM,DD);
  577. If (YY<1980) or (YY>2099) then
  578. Result:=0
  579. else
  580. begin
  581. DecodeTime (DateTime,h,m,s,msec);
  582. Result:=(s shr 1) or (m shl 5) or (h shl 11);
  583. Result:=Result or DD shl 16 or (MM shl 21) or ((YY-1980) shl 25);
  584. end;
  585. end;
  586. Function FileDateToDateTime (Filedate : Longint) : TDateTime;
  587. Var Date,Time : Word;
  588. begin
  589. Date:=FileDate shr 16;
  590. Time:=FileDate and $ffff;
  591. Result:=EncodeDate((Date shr 9) + 1980,(Date shr 5) and 15, Date and 31) +
  592. EncodeTime(Time shr 11, (Time shr 5) and 63, (Time and 31) shl 1,0);
  593. end;
  594. {
  595. $Log$
  596. Revision 1.4 2001-01-18 22:09:09 michael
  597. + Merged fixes from fixbranch - file modes
  598. Revision 1.3 2000/12/16 15:57:16 jonas
  599. * removed 64bit evaluations when range checking is on
  600. Revision 1.2 2000/07/13 11:33:50 michael
  601. + removed logs
  602. }