You've already forked lazarus-ccr
tvplanit: Refactor of dayview painting (preps)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4910 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -62,6 +62,9 @@ const
|
|||||||
HoursInDay = 24; { Number of hours in a day }
|
HoursInDay = 24; { Number of hours in a day }
|
||||||
MinutesInHour = 60; { Number of minutes in an hour }
|
MinutesInHour = 60; { Number of minutes in an hour }
|
||||||
MinutesInDay = 1440; { Number of minutes in a day }
|
MinutesInDay = 1440; { Number of minutes in a day }
|
||||||
|
OneSecond = 1.0 / SecondsInDay;
|
||||||
|
OneMinute = 1.0 / MinutesInDay;
|
||||||
|
OneHour = 1.0 / HoursInDay;
|
||||||
MaxDateLen = 40; { maximum length of date picture strings }
|
MaxDateLen = 40; { maximum length of date picture strings }
|
||||||
MaxMonthName = 15; { maximum length for month names }
|
MaxMonthName = 15; { maximum length for month names }
|
||||||
MaxDayName = 15; { maximum length for day names }
|
MaxDayName = 15; { maximum length for day names }
|
||||||
|
@ -103,6 +103,8 @@ function MonthOfTheYear(TheDate: TDateTime): Word;
|
|||||||
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
||||||
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
||||||
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
|
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
|
||||||
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
|
|
||||||
function GetJulianDate(Date: TDateTime): Word;
|
function GetJulianDate(Date: TDateTime): Word;
|
||||||
@ -127,6 +129,9 @@ function EncodeLineEndings(const AText: String): String;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF LCL}
|
||||||
|
DateUtils,
|
||||||
|
{$ENDIF}
|
||||||
VpException, VpSR;
|
VpException, VpSR;
|
||||||
|
|
||||||
procedure StripString(var Str: string);
|
procedure StripString(var Str: string);
|
||||||
@ -392,7 +397,7 @@ begin
|
|||||||
Sign := 1
|
Sign := 1
|
||||||
else
|
else
|
||||||
Sign := -1;
|
Sign := -1;
|
||||||
Year := Year + (NumMonths div 12);
|
Year := Year + NumMonths div 12;
|
||||||
NumMonths := NumMonths mod 12;
|
NumMonths := NumMonths mod 12;
|
||||||
Inc (Month, NumMonths);
|
Inc (Month, NumMonths);
|
||||||
if Word(Month-1) > 11 then
|
if Word(Month-1) > 11 then
|
||||||
@ -416,10 +421,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
function IncYear (TheDate : TDateTime; NumYears : Integer) : TDateTime;
|
function IncYea (TheDate: TDateTime; NumYear : Integer) : TDateTime;
|
||||||
begin
|
begin
|
||||||
Result := IncMonth (TheDate, NumYears * 12);
|
Result := IncMont (TheDate, NumYears * 12);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
begin
|
||||||
|
Result := trunc(ADateTime);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
||||||
|
begin
|
||||||
|
Result := frac(ADateTime);
|
||||||
|
end;
|
||||||
|
|
||||||
{=====}
|
{=====}
|
||||||
{$ENDIF}{$ENDIF}
|
{$ENDIF}{$ENDIF}
|
||||||
|
|
||||||
@ -455,7 +471,7 @@ var
|
|||||||
Time: Double;
|
Time: Double;
|
||||||
begin
|
begin
|
||||||
{ remove the date part, and add one minute to the time }
|
{ remove the date part, and add one minute to the time }
|
||||||
Time := frac(StartTime) + 1 / MinutesInDay;
|
Time := TimeOf(StartTime) + OneMinute;
|
||||||
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
||||||
result := trunc(Time / LineDuration);
|
result := trunc(Time / LineDuration);
|
||||||
end;
|
end;
|
||||||
@ -467,7 +483,7 @@ var
|
|||||||
Time: Double;
|
Time: Double;
|
||||||
begin
|
begin
|
||||||
{ remove the date part, and subtract one minute from the time }
|
{ remove the date part, and subtract one minute from the time }
|
||||||
Time := frac(EndTime) - 1 / MinutesInDay;
|
Time := TimeOf(EndTime) - OneMinute;
|
||||||
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
||||||
result := trunc(Time / LineDuration);
|
result := trunc(Time / LineDuration);
|
||||||
end;
|
end;
|
||||||
@ -478,8 +494,8 @@ function GetAlarmAdvanceTime(Advance: Integer;
|
|||||||
begin
|
begin
|
||||||
result := 0.0;
|
result := 0.0;
|
||||||
case AdvanceType of
|
case AdvanceType of
|
||||||
atMinutes : result := Advance / MinutesInDay;
|
atMinutes : result := Advance * OneMinute;
|
||||||
atHours : result := Advance * 60 / MinutesInDay;
|
atHours : result := Advance * OneHour;
|
||||||
atDays : result := Advance;
|
atDays : result := Advance;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user