diff --git a/components/tvplanit/source/vpical.pas b/components/tvplanit/source/vpical.pas index 9653296d1..c9d0cf018 100644 --- a/components/tvplanit/source/vpical.pas +++ b/components/tvplanit/source/vpical.pas @@ -65,6 +65,7 @@ type FEndTime: TDateTime; FEndTimeTZ: String; FDuration: double; + FAllDayEvent: Boolean; FRecurrenceFreq: String; FRecurrenceInterval: Integer; FRecurrenceEndDate: TDateTime; @@ -192,6 +193,7 @@ uses VpConst, VpBase; const + DATE_FORMAT = 'yyyymmdd'; TIME_FORMAT = 'yyyymmdd"T"hhnnss'; TIME_FORMAT_UTC = TIME_FORMAT + '"Z"'; @@ -440,9 +442,11 @@ begin FSummary := item.Value; 'DTSTART': begin + s := item.GetAttribute('VALUE'); + FAllDayEvent := (s = 'DATE'); FStartTimeTZ := item.GetAttribute('TZID'); FStartTime := iCalDateTime(item.Value, isUTC); - if not isUTC then + if (not isUTC) and (not FAllDayEvent) then FStartTime := FCalendar.LocalTimeToUTC(FStartTime, FStartTimeTZ); end; 'DTEND': @@ -486,6 +490,15 @@ begin end; end; end; + { + if (FEndTime = NO_DATE) and (FStartTime <> NO_DATE) then + begin + if FDuration = 0 then + FEndTime := FStartTime + 1.0/24 // 1 hour default + else + FEndTime := FStartTime + FDuration; + end; + } end; function TVpICalEvent.Categories: TStrings; @@ -544,6 +557,10 @@ function TVpICalEvent.IsAllDayEvent: Boolean; var tstart, tend: TDateTime; begin + Result := true; + if FAllDayEvent then + exit; + tstart := GetStartTime(false); tend := GetEndTime(false); if ((FEndTime = NO_DATE) or (frac(tend) = 0.0)) and (frac(tstart) = 0.0) then @@ -571,16 +588,21 @@ begin AList.Add('CATEGORIES:' + FCategories.CommaText); // todo: check time zones! - if FStartTimeTZ <> '' then - lKey := 'DTSTART;TZID=' + FStartTimeTZ + ':' + if IsAllDayEvent then + lKey := 'DTSTART;VALUE=DATE:'+ FormatDateTime(DATE_FORMAT, StartTime[true]) else - lKey := 'DTSTART:'; - AList.Add(lKey + FormatDateTime(TIME_FORMAT_UTC, StartTime[true])); - if FEndTimeTZ <> '' then - lKey := 'DTEND;TZID=' + FEndTimeTZ + ':' - else - lKey := 'DTEND:'; - AList.Add(lKey + FormatDateTime(TIME_FORMAT_UTC, EndTime[true])); + begin + if FStartTimeTZ <> '' then + lKey := 'DTSTART;TZID=' + FStartTimeTZ + ':' + else + lKey := 'DTSTART:'; + AList.Add(lKey + FormatDateTime(TIME_FORMAT_UTC, StartTime[true])); + if FEndTimeTZ <> '' then + lKey := 'DTEND;TZID=' + FEndTimeTZ + ':' + else + lKey := 'DTEND:'; + AList.Add(lKey + FormatDateTime(TIME_FORMAT_UTC, EndTime[true])); + end; if RecurrenceFrequency <> '' then begin diff --git a/components/tvplanit/source/vpimportpreview.lfm b/components/tvplanit/source/vpimportpreview.lfm index eb5a96a25..a257f4518 100644 --- a/components/tvplanit/source/vpimportpreview.lfm +++ b/components/tvplanit/source/vpimportpreview.lfm @@ -6,8 +6,8 @@ object VpImportPreviewForm: TVpImportPreviewForm Caption = 'VpImportPreviewForm' ClientHeight = 295 ClientWidth = 634 + LCLVersion = '3.99.0.0' OnShow = FormShow - LCLVersion = '2.3.0.0' object ButtonPanel: TPanel Left = 6 Height = 25 diff --git a/components/tvplanit/source/vpimportpreview.pas b/components/tvplanit/source/vpimportpreview.pas index fff5edcc3..4a19fb673 100644 --- a/components/tvplanit/source/vpimportpreview.pas +++ b/components/tvplanit/source/vpimportpreview.pas @@ -164,7 +164,7 @@ begin FixedCols := 0; Options := [goEditing, goRowSelect, goThumbTracking, goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, - goRangeSelect, goSmoothScroll]; + goRangeSelect]; // Strange scroll effect when using goSmoothScroll... OnDrawCell := @GridDrawCell; OnGetCheckboxState := @GridGetCheckboxState; OnPrepareCanvas := @GridPrepareCanvas; diff --git a/components/tvplanit/source/vpimportpreview_icalevent.pas b/components/tvplanit/source/vpimportpreview_icalevent.pas index 1920d1c74..772664e81 100644 --- a/components/tvplanit/source/vpimportpreview_icalevent.pas +++ b/components/tvplanit/source/vpimportpreview_icalevent.pas @@ -100,8 +100,12 @@ var begin startTime := AEvent.StartTime[false]; endTime := AEvent.EndTime[false]; + sStartTime := FormatDateTime(FTimeFormat, startTime); - sEndTime := FormatDateTime(FTimeFormat, endTime - OneSecond); + if endTime = NO_DATE then + sEndTime := '' + else + sEndTime := FormatDateTime(FTimeFormat, endTime - OneSecond); if AEvent.IsAllDayEvent then begin if endTime = NO_DATE then nDays := 1 else nDays := round(endTime - startTime); @@ -109,6 +113,7 @@ begin Result := Format('%s (%s)', [sStartTime, RSAllDay]) else Result := Format('%s - %s (%s)', [sStartTime, sEndTime, RSAllDay]); + Result := Result + ' (all day)'; end else Result := RSStartTimeLbl + ' ' + sStartTime + LineEnding +