Changeset 34 for trunk/Components/Common/UXMLUtils.pas
- Timestamp:
- Nov 25, 2017, 12:27:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 tunneler.dbg 6 tunneler.lps 5 7 heaptrclog.trc 6 tunneler.lps 8 Components/Common/Languages/*.mo 9 Components/CoolTranslator/Demo/lib
-
- Property svn:ignore
-
trunk/Components/Common/UXMLUtils.pas
r31 r34 7 7 uses 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils ;9 Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM; 10 10 11 11 function XMLTimeToDateTime(XMLDateTime: string): TDateTime; 12 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString; 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 15 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 16 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 17 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 18 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 19 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 20 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 21 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 22 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 13 23 14 24 … … 66 76 Minute: Integer; 67 77 Second: Integer; 78 SecondFraction: Double; 68 79 Millisecond: Integer; 69 80 begin … … 88 99 if Pos('Z', XMLDateTime) > 0 then 89 100 LeftCutString(XMLDateTime, Part, 'Z'); 90 Millisecond := StrToInt(Part); 101 SecondFraction := StrToFloat('0' + DecimalSeparator + Part); 102 Millisecond := Trunc(SecondFraction * 1000); 91 103 end else begin 92 104 if Pos('+', XMLDateTime) > 0 then … … 123 135 end; 124 136 137 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 138 var 139 NewNode: TDOMNode; 140 begin 141 NewNode := Node.OwnerDocument.CreateElement(Name); 142 NewNode.TextContent := IntToStr(Value); 143 Node.AppendChild(NewNode); 144 end; 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 155 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 156 var 157 NewNode: TDOMNode; 158 begin 159 NewNode := Node.OwnerDocument.CreateElement(Name); 160 NewNode.TextContent := BoolToStr(Value); 161 Node.AppendChild(NewNode); 162 end; 163 164 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 165 var 166 NewNode: TDOMNode; 167 begin 168 NewNode := Node.OwnerDocument.CreateElement(Name); 169 NewNode.TextContent := Value; 170 Node.AppendChild(NewNode); 171 end; 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 182 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 183 var 184 NewNode: TDOMNode; 185 begin 186 Result := DefaultValue; 187 NewNode := Node.FindNode(Name); 188 if Assigned(NewNode) then 189 Result := StrToInt(NewNode.TextContent); 190 end; 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 202 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 203 var 204 NewNode: TDOMNode; 205 begin 206 Result := DefaultValue; 207 NewNode := Node.FindNode(Name); 208 if Assigned(NewNode) then 209 Result := StrToBool(NewNode.TextContent); 210 end; 211 212 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 213 var 214 NewNode: TDOMNode; 215 begin 216 Result := DefaultValue; 217 NewNode := Node.FindNode(Name); 218 if Assigned(NewNode) then 219 Result := NewNode.TextContent; 220 end; 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 125 233 end. 126 234
Note:
See TracChangeset
for help on using the changeset viewer.