tvplanit: Use DateUtils functions IncYear etc instead of those implemented in TvPlanIt

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4828 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-24 20:00:32 +00:00
parent b0d583d8a9
commit 70233a6fc4
3 changed files with 24 additions and 43 deletions

View File

@ -96,40 +96,28 @@ procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
function PointInRect(Point: TPoint; Rect: TRect): Boolean;
{-determines if the specified point resides inside the specified TRect }
function GetAlarmAdvanceTime(Advance: Integer;
AdvanceType: TVpAlarmAdvType): TDateTime;
function GetAlarmAdvanceTime(Advance: Integer; AdvanceType: TVpAlarmAdvType): TDateTime;
{$IFNDEF Delphi6}
function MonthOfTheYear (TheDate : TDateTime) : Word;
procedure IncAMonth (var Year, Month, Day : Word; NumMonths : Integer);
function IncMonth(const TheDate : TDateTime;
NumberOfMonths : Integer) : TDateTime;
function IncYear (TheDate : TDateTime; NumYears : Integer) : TDateTime;
{$ENDIF}
{$IFDEF DELPHI}{$IFNDEF Delphi6}
function MonthOfTheYear(TheDate: TDateTime): Word;
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
{$ENDIF}{$ENDIF}
function GetJulianDate(Date: TDateTime): Word;
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
function GetEndLine (EndTime: TDateTime; Granularity: TVpGranularity): Integer;
function GetWeekOfYear(ADate: TDateTime): byte;
function SameDate(dt1, dt2: TDateTime): Boolean;
function TimeInRange(Time, StartTime, EndTime: TDateTime; Inclusive: Boolean): Boolean;
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
function GetEndLine (EndTime: TDateTime; Granularity: TVpGranularity): Integer;
function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime;
function GetLineDuration(Granularity: TVpGranularity): Double;
function GetLabelWidth(ALabel: TLabel): Integer;
function SameDate(dt1, dt2: TDateTime): Boolean;
function GetWeekOfYear(ADate: TDateTime): byte;
implementation
@ -374,10 +362,7 @@ end;
{=====}
{$IFNDEF Delphi6}
{=====}
{$IFDEF DELPHI} {$IFNDEF Delphi6}
function MonthOfTheYear (TheDate : TDateTime) : Word;
var
Year, Day: Word;
@ -390,7 +375,6 @@ procedure IncAMonth (var Year, Month, Day : Word; NumMonths : Integer);
type
PMonthDayTable = ^TMonthDayTable;
TMonthDayTable = array[1..12] of Word;
const
MonthDays: array [Boolean] of TMonthDayTable =
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
@ -398,7 +382,6 @@ const
var
DayTable: PDayTable;
Sign: Integer;
begin
if NumMonths >= 0 then
Sign := 1
@ -433,7 +416,7 @@ begin
Result := IncMonth (TheDate, NumYears * 12);
end;
{=====}
{$ENDIF}
{$ENDIF}{$ENDIF}
function GetJulianDate(Date: TDateTime): Word;
var

View File

@ -444,15 +444,11 @@ type
implementation
uses
VpBaseDS,
VpPrtFmtCBox,
VpPrtPrv,
VpDayView,
VpWeekView,
VpMonthView,
VpCalendar,
VpTaskList,
VpContactGrid;
{$IFDEF LCL}
DateUtils,
{$ENDIF}
VpBaseDS, VpPrtFmtCBox, VpPrtPrv, VpDayView, VpWeekView, VpMonthView,
VpCalendar, VpTaskList, VpContactGrid;
function XMLizeString(const s: string): string;
var

View File

@ -517,6 +517,7 @@ var
HeadTextRect: TRect;
HeadStr: string;
HeadStrLen : Integer;
weekNo: Integer;
begin
RenderCanvas.Brush.Color := RealHeadAttrColor;
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
@ -557,12 +558,13 @@ begin
end;
{ build header caption }
weekNo := GetWeekOfYear(StartDate);
HeadStr := HeadStr + Format('%s %s (%s %d)', [
RSWeekOf, FormatDateTime(FWeekView.DateLabelFormat, StartDate), RSCalendarWeekAbbr, GetWeekOfYear(StartDate)
RSWeekOf, FormatDateTime(FWeekView.DateLabelFormat, StartDate), RSCalendarWeekAbbr, weekNo
]);
// HeadStr := HeadStr + RSWeekof + ' ' + FormatDateTime(DateLabelFormat, StartDate)+' (KW'+IntToStr(GetWeekOfYear(StartDate))+')';
{ draw the text }
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RenderIn.Right - RenderIn.Left)
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= WidthOf(RenderIn))
then
HeadTextRect.TopLeft:= Point(RealLeft + TextMargin * 2, HeadRect.Top)
else