XMLTimeToDateTime ignores milliseconds XMLTimeToDateTime ignores milliseconds xml xml

XMLTimeToDateTime ignores milliseconds


The code in XSBuiltIns indeed parses the millisecond part, but this part is never used in encoding functions.

function TXSBaseTime.GetAsTime: TDateTime;begin  Result := EncodeTime(Hour, Minute, Second, 0);end;

and

function TXSBaseCustomDateTime.GetAsDateTime: TDateTime;var  BiasDT: TDateTime;  BiasTime, BiasLocal: Integer;  BiasHour, BiasMins: Word;begin  { NOTE: In XML Years can exceed 9999 - that's not the case for TDateTime.          So here, there would be a problem with the conversion }  Result := EncodeDateTime(Year, Month, Day, Hour, Minute, Second, 0);

and

function TXSBaseCustomDateTime.GetAsUTCDateTime: TDateTime;var  AdjustDT: TDateTime;begin  Result := EncodeDateTime(Year, Month, Day, Hour, Minute, Second, 0);

As the last one is called from XMLTimeToDateTime, it is quite understandable that the millisecond part is always 0.

All parsing and data storage is done in internal (implementation part) classes which cannot be access directly except through (broken) wrappers. IOW, you should write your own date/time parser.


In addition to all the ugliness found in XSBuiltIns, XMLTimeToDateTime actually parses date twice. First the TXSDateTime.XSToNative is called which parses the date/time, throws result away and stores only the original string, and then TXSCustomDateTime.GetAsUTCDateTime parses this string again. Euch!