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;
|
||||
const AFormatSettings: TFormatSettings);
|
||||
const // isAMPM isLongTime
|
||||
TIME_FMT: array[boolean, boolean] of TsNumberFormat = (
|
||||
(nfShortTime, nfLongTime),
|
||||
(nfShortTimeAM, nfLongTimeAM)
|
||||
);
|
||||
var
|
||||
isPercent: Boolean;
|
||||
number: Double;
|
||||
@ -4958,9 +4963,12 @@ var
|
||||
numFmtParams: TsNumFormatParams;
|
||||
maxDig: Integer;
|
||||
isMixed: Boolean;
|
||||
isAMPM: Boolean;
|
||||
isLongTime: Boolean;
|
||||
rtParams: TsRichTextParams;
|
||||
plain: String;
|
||||
fmtIndex: Integer;
|
||||
ucValue: String;
|
||||
begin
|
||||
if ACell = nil then
|
||||
exit;
|
||||
@ -5047,15 +5055,17 @@ begin
|
||||
begin
|
||||
if not IsTimeFormat(numFmtParams) then
|
||||
begin
|
||||
if IsLongTimeFormat(AValue, AFormatSettings.TimeSeparator) then
|
||||
WriteDateTime(ACell, number, nfLongTime)
|
||||
else
|
||||
WriteDateTime(ACell, number, nfShortTime);
|
||||
ucValue := Uppercase(AValue);
|
||||
isAMPM := (pos('AM', ucValue) > 0) or (pos('PM', ucValue) > 0);
|
||||
isLongTime := IsLongTimeFormat(AValue, AFormatSettings.TimeSeparator);
|
||||
WriteDateTime(ACell, number, TIME_FMT[isAMPM, isLongTime]);
|
||||
end;
|
||||
end else
|
||||
if frac(number) = 0.0 then // this is a date alone
|
||||
begin
|
||||
// if not IsDateFormat(numFmtParams) then
|
||||
if pos(' ', AValue) > 0 then
|
||||
WriteDateTime(ACell, number, nfShortDateTime)
|
||||
else
|
||||
WriteDateTime(ACell, number, nfShortDate);
|
||||
end else
|
||||
if not IsDateTimeFormat(fmt.NumberFormat) then
|
||||
|
@ -507,8 +507,14 @@ begin
|
||||
begin
|
||||
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
|
||||
if (AFormat = sfCSV) and (SollDateTimeFormats[Col] in [nfCustom, nfTimeInterval]) then
|
||||
Continue; // No chance for csv to detect custom formats without further information ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
|
||||
if (AFormat = sfCSV) then begin
|
||||
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);
|
||||
CheckEquals(
|
||||
Lowercase(SollDateTimeStrings[Row, Col]),
|
||||
|
Reference in New Issue
Block a user