You've already forked lazarus-ccr
fpspreadsheet: Fix ISODateTime conversions when local time offset is given
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7967 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3160,6 +3160,7 @@ var
|
|||||||
hours, mins, days: integer;
|
hours, mins, days: integer;
|
||||||
secs: Double;
|
secs: Double;
|
||||||
hrPos, minPos, secPos: integer;
|
hrPos, minPos, secPos: integer;
|
||||||
|
dateStr, timeStr: String;
|
||||||
ms: Double;
|
ms: Double;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
@ -3171,6 +3172,7 @@ begin
|
|||||||
fs.LongTimeFormat := 'hh:nn:ss';
|
fs.LongTimeFormat := 'hh:nn:ss';
|
||||||
fs.Timeseparator := ':';
|
fs.Timeseparator := ':';
|
||||||
|
|
||||||
|
// Check for universal time
|
||||||
if s[Length(s)] = 'Z' then
|
if s[Length(s)] = 'Z' then
|
||||||
begin
|
begin
|
||||||
isUTC := true;
|
isUTC := true;
|
||||||
@ -3181,15 +3183,20 @@ begin
|
|||||||
p := pos('T', s);
|
p := pos('T', s);
|
||||||
if p > 0 then
|
if p > 0 then
|
||||||
begin
|
begin
|
||||||
s[p] := ' ';
|
dateStr := Copy(s, 1, p-1);
|
||||||
|
timeStr := Copy(s, p+1, maxInt);
|
||||||
// Strip milliseconds?
|
// Strip milliseconds?
|
||||||
p := Pos('.', s);
|
p := Pos('.', timeStr);
|
||||||
if (p > 1) then begin
|
if (p > 1) then begin
|
||||||
ms := StrToFloat('0' + Copy(s, p, MaxInt), fs) / SecsPerDay;
|
ms := StrToFloat('0' + Copy(timeStr, p, MaxInt), fs) / SecsPerDay;
|
||||||
s := copy(s, 1, p-1);
|
timeStr := copy(timeStr, 1, p-1);
|
||||||
end else
|
end else
|
||||||
ms := 0;
|
ms := 0;
|
||||||
Result := StrToDateTime(s, fs) + ms;
|
// Strip offset to UTC, we only want local time.
|
||||||
|
p := pos('+', timeStr);
|
||||||
|
if p = 0 then p := pos('-', timeStr);
|
||||||
|
if p > 0 then timeStr := copy(timeStr, 1, p-1);
|
||||||
|
Result := StrToDate(dateStr, fs) + StrToTime(timeStr, fs) + ms;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
p := pos('PT', s);
|
p := pos('PT', s);
|
||||||
|
Reference in New Issue
Block a user