From f1c9fb3597173f5a7a0be5c2355f0b6ef6f4e2cb Mon Sep 17 00:00:00 2001 From: bigchimp Date: Tue, 10 Dec 2013 12:23:02 +0000 Subject: [PATCH] * TsWorksheet.ReadAsUTF8Text: readasdate also reads time values unless sure cell is date-only. Thanks wp for the suggestions! git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2861 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/fpspreadsheet.pas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 3b37af074..8ad39045b 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -689,11 +689,18 @@ begin end; case ACell^.ContentType of - //cctFormula cctNumber: Result := FloatToStrNoNaN(ACell^.NumberValue); cctUTF8String: Result := ACell^.UTF8StringValue; - cctDateTime: Result := SysUtils.DateToStr(ACell^.DateTimeValue); + cctDateTime: + begin + Result := SysUtils.DateToStr(ACell^.DateTimeValue); + // User can have specified custom date/time format or one of the other built + // in formats that include time. We can't parse all of them so just return + // time as well unless absolutely sure we only want a date + if ACell^.NumberFormat<>nfShortDate then + Result := Result+' ' + SysUtils.TimeToStr(ACell^.DateTimeValue); + end; else Result := ''; end;