From 31056b3ac8b5c15a53213427c145ddb54aff0306 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 24 Jun 2016 20:03:19 +0000 Subject: [PATCH] tvplanit: Add comment that GetWeekOfYear (in VpMisc) calculates week number according to ISO specification. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4829 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpmisc.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 72f8e5a16..e9228f030 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -597,15 +597,16 @@ begin Result := trunc(dt1) = trunc(dt2); end; +// Calculates ISO week number (checked with Jan 1, 2016, which is in week 53). function GetWeekOfYear(ADate: TDateTime): byte; -// was in TvWeekView +// was in TvWeekView. var yr, dummy: word; First: TDateTime; begin DecodeDate(ADate + (8 - DayOfWeek(ADate)) mod 7 - 3, yr, dummy,dummy); First := EncodeDate(yr, 1, 1); - Result := (trunc(ADate - First - 3 + (DayOfWeek(First) + 1) mod 7) div 7) + 1; + Result := trunc(ADate - First - 3 + (DayOfWeek(First) + 1) mod 7) div 7 + 1; end;