You've already forked lazarus-ccr
tvplanit: Improved handling of all-day events in ical files.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9088 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -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,6 +588,10 @@ begin
|
||||
AList.Add('CATEGORIES:' + FCategories.CommaText);
|
||||
|
||||
// todo: check time zones!
|
||||
if IsAllDayEvent then
|
||||
lKey := 'DTSTART;VALUE=DATE:'+ FormatDateTime(DATE_FORMAT, StartTime[true])
|
||||
else
|
||||
begin
|
||||
if FStartTimeTZ <> '' then
|
||||
lKey := 'DTSTART;TZID=' + FStartTimeTZ + ':'
|
||||
else
|
||||
@ -581,6 +602,7 @@ begin
|
||||
else
|
||||
lKey := 'DTEND:';
|
||||
AList.Add(lKey + FormatDateTime(TIME_FORMAT_UTC, EndTime[true]));
|
||||
end;
|
||||
|
||||
if RecurrenceFrequency <> '' then
|
||||
begin
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -100,7 +100,11 @@ var
|
||||
begin
|
||||
startTime := AEvent.StartTime[false];
|
||||
endTime := AEvent.EndTime[false];
|
||||
|
||||
sStartTime := FormatDateTime(FTimeFormat, startTime);
|
||||
if endTime = NO_DATE then
|
||||
sEndTime := ''
|
||||
else
|
||||
sEndTime := FormatDateTime(FTimeFormat, endTime - OneSecond);
|
||||
if AEvent.IsAllDayEvent then
|
||||
begin
|
||||
@ -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 +
|
||||
|
Reference in New Issue
Block a user