You've already forked lazarus-ccr
fpspreadsheet: Fix csv unit test fails of some date/time values.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5778 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4950,6 +4950,11 @@ end;
|
|||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsWorksheet.WriteCellValueAsString(ACell: PCell; AValue: String;
|
procedure TsWorksheet.WriteCellValueAsString(ACell: PCell; AValue: String;
|
||||||
const AFormatSettings: TFormatSettings);
|
const AFormatSettings: TFormatSettings);
|
||||||
|
const // isAMPM isLongTime
|
||||||
|
TIME_FMT: array[boolean, boolean] of TsNumberFormat = (
|
||||||
|
(nfShortTime, nfLongTime),
|
||||||
|
(nfShortTimeAM, nfLongTimeAM)
|
||||||
|
);
|
||||||
var
|
var
|
||||||
isPercent: Boolean;
|
isPercent: Boolean;
|
||||||
number: Double;
|
number: Double;
|
||||||
@ -4958,9 +4963,12 @@ var
|
|||||||
numFmtParams: TsNumFormatParams;
|
numFmtParams: TsNumFormatParams;
|
||||||
maxDig: Integer;
|
maxDig: Integer;
|
||||||
isMixed: Boolean;
|
isMixed: Boolean;
|
||||||
|
isAMPM: Boolean;
|
||||||
|
isLongTime: Boolean;
|
||||||
rtParams: TsRichTextParams;
|
rtParams: TsRichTextParams;
|
||||||
plain: String;
|
plain: String;
|
||||||
fmtIndex: Integer;
|
fmtIndex: Integer;
|
||||||
|
ucValue: String;
|
||||||
begin
|
begin
|
||||||
if ACell = nil then
|
if ACell = nil then
|
||||||
exit;
|
exit;
|
||||||
@ -5047,15 +5055,17 @@ begin
|
|||||||
begin
|
begin
|
||||||
if not IsTimeFormat(numFmtParams) then
|
if not IsTimeFormat(numFmtParams) then
|
||||||
begin
|
begin
|
||||||
if IsLongTimeFormat(AValue, AFormatSettings.TimeSeparator) then
|
ucValue := Uppercase(AValue);
|
||||||
WriteDateTime(ACell, number, nfLongTime)
|
isAMPM := (pos('AM', ucValue) > 0) or (pos('PM', ucValue) > 0);
|
||||||
else
|
isLongTime := IsLongTimeFormat(AValue, AFormatSettings.TimeSeparator);
|
||||||
WriteDateTime(ACell, number, nfShortTime);
|
WriteDateTime(ACell, number, TIME_FMT[isAMPM, isLongTime]);
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
if frac(number) = 0.0 then // this is a date alone
|
if frac(number) = 0.0 then // this is a date alone
|
||||||
begin
|
begin
|
||||||
// if not IsDateFormat(numFmtParams) then
|
if pos(' ', AValue) > 0 then
|
||||||
|
WriteDateTime(ACell, number, nfShortDateTime)
|
||||||
|
else
|
||||||
WriteDateTime(ACell, number, nfShortDate);
|
WriteDateTime(ACell, number, nfShortDate);
|
||||||
end else
|
end else
|
||||||
if not IsDateTimeFormat(fmt.NumberFormat) then
|
if not IsDateTimeFormat(fmt.NumberFormat) then
|
||||||
|
@ -507,8 +507,14 @@ begin
|
|||||||
begin
|
begin
|
||||||
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||||
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
||||||
if (AFormat = sfCSV) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
if (AFormat = sfCSV) then begin
|
||||||
Continue; // No chance for csv to detect custom formats without further information ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
if (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||||
|
Continue; // No chance for csv to detect custom formats without further information ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
||||||
|
if (SollDateTimeFormats[Col] in [nfShortDate, nfLongDate, nfShortDateTime])
|
||||||
|
and (SollDateTimes[Row] < 1)
|
||||||
|
then
|
||||||
|
Continue; // No chance for csv to detect a datetime format < 1 (must be time only)
|
||||||
|
end;
|
||||||
ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
||||||
CheckEquals(
|
CheckEquals(
|
||||||
Lowercase(SollDateTimeStrings[Row, Col]),
|
Lowercase(SollDateTimeStrings[Row, Col]),
|
||||||
|
Reference in New Issue
Block a user