You've already forked lazarus-ccr
* LibreOffice/ODS format: fix time-only calculations exceeding EncodeDate limits
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2909 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -288,7 +288,7 @@ begin
|
|||||||
// Don't merge, or else we can't debug
|
// Don't merge, or else we can't debug
|
||||||
Str := GetAttrValue(ACellNode,'office:value');
|
Str := GetAttrValue(ACellNode,'office:value');
|
||||||
lNumber := StrToFloat(Str,FSettings);
|
lNumber := StrToFloat(Str,FSettings);
|
||||||
FWorkSheet.WriteNumber(Arow,ACol,lNumber);
|
FWorkSheet.WriteNumber(ARow,ACol,lNumber);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -327,35 +327,34 @@ begin
|
|||||||
Value:=GetAttrValue(ACellNode,'office:time-value');
|
Value:=GetAttrValue(ACellNode,'office:time-value');
|
||||||
if (Value<>'') and (Pos('PT',Value)=1) then
|
if (Value<>'') and (Pos('PT',Value)=1) then
|
||||||
begin
|
begin
|
||||||
dt:=DATEMODE_1900_BASE; //todo: detect based on sheet format; see xls code
|
|
||||||
// Get hours
|
// Get hours
|
||||||
HoursPos:=Pos('H',Value);
|
HoursPos:=Pos('H',Value);
|
||||||
if (HoursPos>0) then
|
if (HoursPos>0) then
|
||||||
begin
|
Hours:=StrToInt(Copy(Value,3,HoursPos-3))
|
||||||
Hours:=StrToInt(Copy(Value,3,HoursPos-3));
|
else
|
||||||
case Hours of
|
Hours:=0;
|
||||||
0..23: dt:=dt+EncodeTime(Hours,0,0,0)
|
|
||||||
else dt:=dt+EncodeDateTime(0,0,Hours div 24,Hours mod 24,0,0,0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Get minutes
|
// Get minutes
|
||||||
MinutesPos:=Pos('M',Value);
|
MinutesPos:=Pos('M',Value);
|
||||||
if (MinutesPos>0) and (MinutesPos>HoursPos) then
|
if (MinutesPos>0) and (MinutesPos>HoursPos) then
|
||||||
begin
|
Minutes:=StrToInt(Copy(Value,HoursPos+1,MinutesPos-HoursPos-1))
|
||||||
Minutes:=StrToInt(Copy(Value,HoursPos+1,MinutesPos-HoursPos-1));
|
else
|
||||||
if Minutes>0 then
|
Minutes:=0;
|
||||||
dt:=dt+EncodeTime(Minutes div 60,Minutes mod 60,0,0)
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Get seconds
|
// Get seconds
|
||||||
SecondsPos:=Pos('S',Value);
|
SecondsPos:=Pos('S',Value);
|
||||||
if (SecondsPos>0) and (SecondsPos>MinutesPos) then
|
if (SecondsPos>0) and (SecondsPos>MinutesPos) then
|
||||||
begin
|
Seconds:=StrToInt(Copy(Value,MinutesPos+1,SecondsPos-MinutesPos-1))
|
||||||
Seconds:=StrToInt(Copy(Value,MinutesPos+1,SecondsPos-MinutesPos-1));
|
else
|
||||||
if Seconds>0 then
|
Seconds:=0;
|
||||||
dt:=dt+EncodeTime(0,Seconds div 60,Seconds mod 60,0)
|
|
||||||
end;
|
// Convert to date/time via Unix timestamp so avoiding limits for number of
|
||||||
|
// hours etc in EncodeDateTime. Perhaps there's a faster way of doing this?
|
||||||
|
dt:=DATEMODE_1900_BASE-UnixEpoch-1+UnixToDateTime(
|
||||||
|
Hours*(MinsPerHour*SecsPerMin)+
|
||||||
|
Minutes*(SecsPerMin)+
|
||||||
|
Seconds
|
||||||
|
); //todo: detect actually used date mode based on file settings; see xls code
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
FWorkSheet.WriteDateTime(Arow,ACol,dt);
|
FWorkSheet.WriteDateTime(Arow,ACol,dt);
|
||||||
|
Reference in New Issue
Block a user