dati.inc 19 KB

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