Changeset 192 for trunk/Packages/Common/UXMLUtils.pas
- Timestamp:
- May 1, 2018, 10:18:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UXMLUtils.pas
r109 r192 7 7 uses 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils, XMLRead, XMLWrite,DOM;9 Classes, SysUtils, DateUtils, DOM; 10 10 11 11 function XMLTimeToDateTime(XMLDateTime: string): TDateTime; 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 13 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); … … 30 30 TimeZoneInfo: TTimeZoneInformation; 31 31 begin 32 {$push}{$warn 5057 off} 32 33 case GetTimeZoneInformation(TimeZoneInfo) of 33 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias;34 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias;34 TIME_ZONE_ID_STANDARD: Result := TimeZoneInfo.Bias + TimeZoneInfo.StandardBias; 35 TIME_ZONE_ID_DAYLIGHT: Result := TimeZoneInfo.Bias + TimeZoneInfo.DaylightBias; 35 36 else 36 37 Result := 0; 37 38 end; 39 {$pop} 38 40 end; 39 41 {$ELSE} … … 45 47 function LeftCutString(var Source: string; out Output: string; Delimiter: string; Allowed: string = ''): Boolean; 46 48 var 47 I , J: Integer;49 I: Integer; 48 50 Matched: Boolean; 49 51 begin … … 99 101 if Pos('Z', XMLDateTime) > 0 then 100 102 LeftCutString(XMLDateTime, Part, 'Z'); 101 SecondFraction := StrToFloat('0' + De cimalSeparator + Part);103 SecondFraction := StrToFloat('0' + DefaultFormatSettings.DecimalSeparator + Part); 102 104 Millisecond := Trunc(SecondFraction * 1000); 103 105 end else begin … … 118 120 end; 119 121 120 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;122 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): string; 121 123 const 122 124 Neg: array[Boolean] of string = ('+', '-'); … … 139 141 NewNode: TDOMNode; 140 142 begin 141 NewNode := Node.OwnerDocument.CreateElement( Name);142 NewNode.TextContent := IntToStr(Value);143 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 144 NewNode.TextContent := DOMString(IntToStr(Value)); 143 145 Node.AppendChild(NewNode); 144 146 end; … … 148 150 NewNode: TDOMNode; 149 151 begin 150 NewNode := Node.OwnerDocument.CreateElement( Name);151 NewNode.TextContent := IntToStr(Value);152 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 153 NewNode.TextContent := DOMString(IntToStr(Value)); 152 154 Node.AppendChild(NewNode); 153 155 end; … … 157 159 NewNode: TDOMNode; 158 160 begin 159 NewNode := Node.OwnerDocument.CreateElement( Name);160 NewNode.TextContent := BoolToStr(Value);161 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 162 NewNode.TextContent := DOMString(BoolToStr(Value)); 161 163 Node.AppendChild(NewNode); 162 164 end; … … 166 168 NewNode: TDOMNode; 167 169 begin 168 NewNode := Node.OwnerDocument.CreateElement( Name);169 NewNode.TextContent := Value;170 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 171 NewNode.TextContent := DOMString(Value); 170 172 Node.AppendChild(NewNode); 171 173 end; … … 175 177 NewNode: TDOMNode; 176 178 begin 177 NewNode := Node.OwnerDocument.CreateElement( Name);178 NewNode.TextContent := D ateTimeToXMLTime(Value);179 NewNode := Node.OwnerDocument.CreateElement(DOMString(Name)); 180 NewNode.TextContent := DOMString(DateTimeToXMLTime(Value)); 179 181 Node.AppendChild(NewNode); 180 182 end; … … 185 187 begin 186 188 Result := DefaultValue; 187 NewNode := Node.FindNode( Name);188 if Assigned(NewNode) then 189 Result := StrToInt( NewNode.TextContent);189 NewNode := Node.FindNode(DOMString(Name)); 190 if Assigned(NewNode) then 191 Result := StrToInt(string(NewNode.TextContent)); 190 192 end; 191 193 … … 195 197 begin 196 198 Result := DefaultValue; 197 NewNode := Node.FindNode( Name);198 if Assigned(NewNode) then 199 Result := StrToInt64( NewNode.TextContent);199 NewNode := Node.FindNode(DOMString(Name)); 200 if Assigned(NewNode) then 201 Result := StrToInt64(string(NewNode.TextContent)); 200 202 end; 201 203 … … 205 207 begin 206 208 Result := DefaultValue; 207 NewNode := Node.FindNode( Name);208 if Assigned(NewNode) then 209 Result := StrToBool( NewNode.TextContent);209 NewNode := Node.FindNode(DOMString(Name)); 210 if Assigned(NewNode) then 211 Result := StrToBool(string(NewNode.TextContent)); 210 212 end; 211 213 … … 215 217 begin 216 218 Result := DefaultValue; 217 NewNode := Node.FindNode( Name);218 if Assigned(NewNode) then 219 Result := NewNode.TextContent;219 NewNode := Node.FindNode(DOMString(Name)); 220 if Assigned(NewNode) then 221 Result := string(NewNode.TextContent); 220 222 end; 221 223 … … 226 228 begin 227 229 Result := DefaultValue; 228 NewNode := Node.FindNode( Name);229 if Assigned(NewNode) then 230 Result := XMLTimeToDateTime( NewNode.TextContent);230 NewNode := Node.FindNode(DOMString(Name)); 231 if Assigned(NewNode) then 232 Result := XMLTimeToDateTime(string(NewNode.TextContent)); 231 233 end; 232 234
Note:
See TracChangeset
for help on using the changeset viewer.