From 70233a6fc4a9e4b4c1723ef5a1c6c7c24956319a Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 24 Jun 2016 20:00:32 +0000 Subject: [PATCH] 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 --- components/tvplanit/source/vpmisc.pas | 45 ++++++------------- components/tvplanit/source/vpprtfmt.pas | 14 +++--- .../tvplanit/source/vpweekviewpainter.pas | 8 ++-- 3 files changed, 24 insertions(+), 43 deletions(-) diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 2e183ea86..72f8e5a16 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -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 diff --git a/components/tvplanit/source/vpprtfmt.pas b/components/tvplanit/source/vpprtfmt.pas index 238543a24..1e0b6d243 100644 --- a/components/tvplanit/source/vpprtfmt.pas +++ b/components/tvplanit/source/vpprtfmt.pas @@ -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 diff --git a/components/tvplanit/source/vpweekviewpainter.pas b/components/tvplanit/source/vpweekviewpainter.pas index 5b5b6d876..a9964960b 100644 --- a/components/tvplanit/source/vpweekviewpainter.pas +++ b/components/tvplanit/source/vpweekviewpainter.pas @@ -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