Changeset 15 for trunk/Packages/Common/UXMLUtils.pas
- Timestamp:
- Mar 22, 2018, 8:31:19 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UXMLUtils.pas
r10 r15 12 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString; 13 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 14 15 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 15 16 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 17 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 16 18 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 19 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 17 20 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 18 21 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 22 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 19 23 20 24 … … 72 76 Minute: Integer; 73 77 Second: Integer; 78 SecondFraction: Double; 74 79 Millisecond: Integer; 75 80 begin … … 94 99 if Pos('Z', XMLDateTime) > 0 then 95 100 LeftCutString(XMLDateTime, Part, 'Z'); 96 Millisecond := StrToInt(Part); 101 SecondFraction := StrToFloat('0' + DecimalSeparator + Part); 102 Millisecond := Trunc(SecondFraction * 1000); 97 103 end else begin 98 104 if Pos('+', XMLDateTime) > 0 then … … 138 144 end; 139 145 146 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 147 var 148 NewNode: TDOMNode; 149 begin 150 NewNode := Node.OwnerDocument.CreateElement(Name); 151 NewNode.TextContent := IntToStr(Value); 152 Node.AppendChild(NewNode); 153 end; 154 140 155 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 141 156 var … … 156 171 end; 157 172 173 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 174 var 175 NewNode: TDOMNode; 176 begin 177 NewNode := Node.OwnerDocument.CreateElement(Name); 178 NewNode.TextContent := DateTimeToXMLTime(Value); 179 Node.AppendChild(NewNode); 180 end; 181 158 182 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 159 183 var … … 166 190 end; 167 191 192 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 193 var 194 NewNode: TDOMNode; 195 begin 196 Result := DefaultValue; 197 NewNode := Node.FindNode(Name); 198 if Assigned(NewNode) then 199 Result := StrToInt64(NewNode.TextContent); 200 end; 201 168 202 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 169 203 var … … 186 220 end; 187 221 222 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime 223 ): TDateTime; 224 var 225 NewNode: TDOMNode; 226 begin 227 Result := DefaultValue; 228 NewNode := Node.FindNode(Name); 229 if Assigned(NewNode) then 230 Result := XMLTimeToDateTime(NewNode.TextContent); 231 end; 232 188 233 end. 189 234
Note:
See TracChangeset
for help on using the changeset viewer.