Re: [Lazarus] lhelp command line

2013-11-12 Thread Reinier Olislagers
On 10/11/2013 19:05, waldo kitty wrote:
 
 how does one get lhelp to load all or a certain set of chm files
 from the command line?
 

If it doesn't work, it probably isn't implemented in lhelp command line
handling.
The lazarus chmhelp package that is used to control lhelp currently does
load all chms in your chm directory/directories, so you could submit a
patch based on the code there.

Let me know if you want me to dig up the exact location of that code.

 additionally, from within lhelp, File-Open only allows one file at
 a time to be specified... you can't CTRL-Click on multiple or
 SHIFT-Click to grab a bunch in a row...
Probably needs some property for the file picker set to enable multi
file selection (sorry, not much of a GUI guy myself) and the rest of the
code in lhelp adjusted?

-- 
NOTE: No assistance is given without prior written approval in blood.
  Please keep mailing list traffic on the list unless
  private contact is specifically requested and granted by
  RFC 1149 message.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Bart
On 11/12/13, Michael Van Canneyt mich...@freepascal.org wrote:

 Feel free to provide other functions, I will happily accept them.

I proposed a solution in this thread.
It'll give you (at least that was the intention) the years, months,
and days between two (Gregorian) dates.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Frederic Da Vitoria
2013/11/12 Michael Van Canneyt mich...@freepascal.org


 On Tue, 12 Nov 2013, Jürgen Hestermann wrote:

  Am 2013-11-11 17:25, schrieb Michael Van Canneyt:

 The number of elapsed DAYS between these 2 dates is 60.
 If the average number of days per month is assumed to be 30.4375, then 2

 full months would be 60.875 days.

 That means that 60 days DOES NOT span 2 full months of 30.4375 days: it

 falls 0.875 days short for that.

 Hence, the *intended* result is 1.


 But dates from the 1st of a month to the 1st of the next month
 should be considered to span a full month, shouldn't it?
 If not, of what use would it be?
 A month is *not* defined to be 30.4375 days.
 Getting an average months is completely useless IMO.
 Who wants to get such a result for what purpose?


 Like I said: you can argue whether the functions are useful.
 They are there for Delphi compatibility.

 Feel free to provide other functions, I will happily accept them.


If I am not mistaken, Bart just provided one :-) I suggest using another
more discriminant name instead of DateDiff, something like AgeBetween or
ExactDateDiff.

-- 
Frederic Da Vitoria
(davitof)

Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Lazarus with fpc 2.7.1

2013-11-12 Thread Reinier Olislagers
On 11/11/2013 14:26, Edson F. Lidorio wrote:
 checkedin the repositoriesbelowandareoutdatedthe2.7

Those are (almost certainly) not svn repositories.
Have a look at the documentation, e.g.
http://freepascal.org/develop.var


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Local CHM help files or web based?

2013-11-12 Thread Richard Mace
Hi all, I'm just about to start writing help files for my application but I
can't work out whether to use web based ones or local c h m ones any ideas
welcome?

Richard
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread John Landmesser

On 12.11.2013 13:05, Bart wrote:


I proposed a solution in this thread.
It'll give you (at least that was the intention) the years, months,
and days between two (Gregorian) dates.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Hi Bart,

i found this in old RxLib ( now Yedi ).

Perhaps it inspires you.

procedure DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: word);
var
  DtSwap: TDateTime;
  Day1, Day2, Month1, Month2, Year1, Year2: word;
begin
  if Date1  Date2 then
  begin
DtSwap := Date1;
Date1 := Date2;
Date2 := DtSwap;
  end;
  DecodeDate(Date1, Year1, Month1, Day1);
  DecodeDate(Date2, Year2, Month2, Day2);
  Years := Year2 - Year1;
  Months := 0;
  Days := 0;
  if Month2  Month1 then
  begin
Inc(Months, 12);
Dec(Years);
  end;
  Inc(Months, Month2 - Month1);
  if Day2  Day1 then
  begin
// von mir auskommentiert Inc(Days, DaysPerMonth(Year1, Month1));
Inc(Days, DaysInAMonth(Year1, Month1));
if Months = 0 then
begin
  Dec(Years);
  Months := 11;
end
else
  Dec(Months);
  end;
  Inc(Days, Day2 - Day1);
end;


My Tests showed: this procedure works well !

The next function seems also much better than that in DateUtil:

function MonthsBetween(Date1, Date2: TDateTime): Double;
var
  D, M, Y: Word;
begin
  DateDiff(Date1, Date2, D, M, Y);
  Result := 12 * Y + M;
  if (D  1) and (D  7) then Result := Result + 0.25
  else if (D = 7) and (D  15) then Result := Result + 0.5
  else if (D = 15) and (D  21) then Result := Result + 0.75
  else if (D = 21) then Result := Result + 1;
end;

Problem: it returns Double!!

I'll use these two and i think everything is ok?!!

happy hacking ...

John

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Local CHM help files or web based?

2013-11-12 Thread leledumbo
CHM for me, it has nice features that web based one can't do fast.



--
View this message in context: 
http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Local-CHM-help-files-or-web-based-tp4034271p4034272.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] CopyFile in Windows

2013-11-12 Thread Alejandro Gonzalo
Just put Windows last in the uses clause.
 
A..--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Can't enter negative values in to TFloatSpinEdit

2013-11-12 Thread Valdas Jankūnas

Helo,

situation:
- os: Linux Kubuntu 13.10;
- Lazarus: Lazarus 1.3 r43416M FPC 2.6.2 x86_64-linux-qt;
- locale: LANG=lt_LT.UTF-8, LANGUAGE=lt, LC_*=lt_LT.UTF-8, LC_ALL=
- Form's WS: qt;
- on Form is placed TFloatSpinEdit (Max:100, Min:-100).

 When program is running I can't enter negative values:
- select all, pres minus sign button (hex: 2D) - minus appears, press 
any digit - no reaction;

- select all, press any digit - digits appears;
- select all, paste (Right click - Paste) -4 prom text editor - 
nothing changes;

- select all, paste 3 from editor - text accepted.

 Why? Is it known problem?

--
  Valdas Jankūnas

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread waldo kitty

On 11/11/2013 6:54 PM, waldo kitty wrote:

On 11/11/2013 10:46 AM, John Landmesser wrote:

Fazit:

You can't write a DateDif function with the functions in DateUtils.pas ?!!


actually, you can but it is more brute-force for the results that you and i are
looking for... brute-force as in actually looping thru each unit and
incrementing a counter for that part to fill a record of some sort which is then
used to show the desired counts... i'm working on one as we speak ;)


it is amazing what refinements and streamlining will come up with at times... 
originally this was totally brute force... then i started refining and cleaning 
it up until i came up with this... it also includes a set of a set of dates for 
testing...



= snip =
program DateDiff3;

uses
  SysUtils,DateUtils,StrUtils;

type
  Date_Diff = record
Years,
Months,
Days: Word;
  end;

function CalendarDateDiff(Date1,Date2: TDateTime): Date_Diff;
var
  theDiffRec: Date_Diff;
  Cmp: Integer;
  loDate,hiDate: TDateTime;
  loYear,hiYear,loMonth,hiMonth,loDay,hiDay: Word;
begin
  FillChar(theDiffRec,SizeOf(theDiffRec),0);  // init results to zero
  Cmp:=CompareDateTime(Date1,Date2);  // compare dates
  If Cmp0 then
  begin
loDate:= Date1;   // and set loDate to oldest
hiDate:= Date2;
  end
  else if Cmp0 then
  begin
loDate:= Date2;   // and set loDate to oldest
hiDate:= Date1;
  end;
  DecodeDate(loDate,loYear,loMonth,loDay);
  DecodeDate(hiDate,hiYear,hiMonth,hiDay);
  theDiffRec.Years:= hiYear - loYear;
  if (loMonth  hiMonth) or ((loMonth = hiMonth) and (loDay  hiDay)) then
  begin
theDiffRec.Years:= theDiffRec.Years - 1;
  end;
  if loMonth  hiMonth then
  begin
hiMonth:= hiMonth + 12;
  end;
  theDiffRec.Months:= hiMonth - loMonth;
  if hiDay = loDay then
  begin
theDiffRec.Days:= hiDay - loDay
  end
  else
  begin
if theDiffRec.Months = 0 then
begin
  theDiffRec.Months:= 11;
end
else
begin
  theDiffRec.Months:= theDiffRec.Months - 1;
end;
theDiffRec.Days:= DaysInAMonth(hiYear,loMonth) - loDay + hiDay;
  end;
  Result:= theDiffRec;
end;

procedure Test(D1,D2: TDateTime);
var
  DateDiffRec: Date_Diff;
begin
  FillChar(DateDiffRec,SizeOf(DateDiffRec),0);
  DateDiffRec:= CalendarDateDiff(D1,D2);
  writeln(PadLeft(IntToStr(DateDiffRec.Years),4)+' yrs 
'+PadLeft(IntToStr(DateDiffRec.Months),4)+' mos 
'+PadLeft(IntToStr(DateDiffRec.Days),4)+' days');

end;

type
  DateRecord = record
 Year,
 Month,
 Day: Word;
   end;
const
  TstDates1: array[1..26] of DateRecord = (
   (Year:2000;Month:01;Day:01),
   (Year:2000;Month:01;Day:02),
   (Year:2000;Month:01;Day:31),
   (Year:2000;Month:02;Day:01),
   (Year:2000;Month:02;Day:28),
   (Year:2000;Month:02;Day:29),
   (Year:2000;Month:03;Day:01),
   (Year:2000;Month:03;Day:15),
   (Year:2000;Month:12;Day:31),
   (Year:2001;Month:01;Day:01),
   (Year:2001;Month:01;Day:02),
   (Year:2001;Month:02;Day:01),
   (Year:2001;Month:02;Day:28),
   (Year:2001;Month:02;Day:29),
   (Year:2001;Month:03;Day:01),
   (Year:2001;Month:03;Day:15),
   (Year:2001;Month:08;Day:01),
   (Year:2001;Month:12;Day:31),
   (Year:2004;Month:01;Day:01),
   (Year:2004;Month:01;Day:02),
   (Year:2004;Month:02;Day:01),
   (Year:2004;Month:02;Day:28),
   (Year:2004;Month:02;Day:29),
   (Year:2004;Month:03;Day:01),
   (Year:2004;Month:03;Day:15),
   (Year:2004;Month:12;Day:31)
  );
  TstDates2: Array[1..26] of DateRecord = (
   (Year:2000;Month:01;Day:01),
   (Year:2000;Month:01;Day:02),
   (Year:2000;Month:01;Day:31),
   (Year:2000;Month:02;Day:01),
  

Re: [Lazarus] Can't enter negative values in to TFloatSpinEdit

2013-11-12 Thread Avishai
I work with Windows so it may be different.  I set
TFloatSpinEdit.MinValue:= -100 and I can enter negative values.

On Tue, Nov 12, 2013 at 9:36 PM, Valdas Jankūnas zmu...@gmail.com wrote:
 Helo,

 situation:
 - os: Linux Kubuntu 13.10;
 - Lazarus: Lazarus 1.3 r43416M FPC 2.6.2 x86_64-linux-qt;
 - locale: LANG=lt_LT.UTF-8, LANGUAGE=lt, LC_*=lt_LT.UTF-8, LC_ALL=
 - Form's WS: qt;
 - on Form is placed TFloatSpinEdit (Max:100, Min:-100).

  When program is running I can't enter negative values:
 - select all, pres minus sign button (hex: 2D) - minus appears, press any
 digit - no reaction;
 - select all, press any digit - digits appears;
 - select all, paste (Right click - Paste) -4 prom text editor - nothing
 changes;
 - select all, paste 3 from editor - text accepted.

  Why? Is it known problem?

 --
   Valdas Jankūnas

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



-- 
Shalom,
Avishai
avishai.g...@gmail.com
אבישי גוֹר

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread waldo kitty



*FWIW*

On 11/11/2013 5:11 PM, Bart wrote:


type
   TDaysPerMonth = Array[1..12] of Word;


function DaysPerMonth(AMonth: Word; IsLeapYear: Boolean): Word;
const
   DaysPerMonthNormal: TDaysPerMonth = (31,28,31,30,31,30,31,31,30,31,30,31);
   DaysPerMonthLeap:   TDaysPerMonth = (31,29,31,30,31,30,31,31,30,31,30,31);
begin
   if IsLeapYear then
 Result := DaysPerMonthLeap[AMonth]
   else
Result := DaysPerMonthNormal[AMonth];
end;


you do not need any of the above if you change


 Days := (DaysPerMonth(M1, IsLeapYear(Y2)) - D1) + D2 ;


to

  Days := (DaysInAMonth(Y2,M1) - D1) + D2;

this because DaysInAMonth returns the correct number of days and takes leapyear 
into account automatically... so there's no reason to duplicate existing code 
with the above type and function ;)


outside of this, what you came up with is almost exactly what i worked my way 
down to as i was working on my own solution... it took me a while and then when 
i saw your post, i was astonished at how the mind works at times :LOL:


--
NOTE: No off-list assistance is given without prior approval.
  Please keep mailing list traffic on the list unless
  private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] CopyFile in Windows

2013-11-12 Thread Richard Mace
Spot on. Can't believe I missed that.

Thanks


On 11 November 2013 20:48, Luca Olivetti l...@wetron.es wrote:

 Al 11/11/13 18:14, En/na Jürgen Hestermann ha escrit:
 
  So either you remove the windows unit or, if not possible,
  you need to fully qualify from which unit you want to call CopyFile (I
  don't know where it's defined).

 in FileUtil.
 Note that, differently than the windows CopyFile function (which returns
 an error code), FileUtil.CopyFile will throw an exception in case of error.

 Bye

 --
 Luca Olivetti
 Wetron Automation Technology http://www.wetron.es
 Tel. +34 935883004  Fax +34 935883007

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread John Landmesser

On 12.11.2013 21:01, waldo kitty wrote:

type
  Date_Diff = record
Years,
Months,
Days: Word;
  end;

function CalendarDateDiff(Date1,Date2: TDateTime): Date_Diff;
var
  theDiffRec: Date_Diff;
  Cmp: Integer;
  loDate,hiDate: TDateTime;
  loYear,hiYear,loMonth,hiMonth,loDay,hiDay: Word;
begin
  FillChar(theDiffRec,SizeOf(theDiffRec),0);  // init results to zero
  Cmp:=CompareDateTime(Date1,Date2);  // compare dates
  If Cmp0 then
  begin
loDate:= Date1;   // and set loDate to oldest
hiDate:= Date2;
  end
  else if Cmp0 then
  begin
loDate:= Date2;   // and set loDate to oldest
hiDate:= Date1;
  end;
  DecodeDate(loDate,loYear,loMonth,loDay);
  DecodeDate(hiDate,hiYear,hiMonth,hiDay);
  theDiffRec.Years:= hiYear - loYear;
  if (loMonth  hiMonth) or ((loMonth = hiMonth) and (loDay  hiDay)) 
then

  begin
theDiffRec.Years:= theDiffRec.Years - 1;
  end;
  if loMonth  hiMonth then
  begin
hiMonth:= hiMonth + 12;
  end;
  theDiffRec.Months:= hiMonth - loMonth;
  if hiDay = loDay then
  begin
theDiffRec.Days:= hiDay - loDay
  end
  else
  begin
if theDiffRec.Months = 0 then
begin
  theDiffRec.Months:= 11;
end
else
begin
  theDiffRec.Months:= theDiffRec.Months - 1;
end;
theDiffRec.Days:= DaysInAMonth(hiYear,loMonth) - loDay + hiDay;
  end;
  Result:= theDiffRec;
end; 


Which is correct?

Date1 := 29.2.2000
Date2 := 28.02.2001

Your function:
0 Y, 11 M, 27 D

Rxlib ( Jedi ) DateDiff:
0 Y, 11 M, 28 D

Libre Office Calc:
0 Y, 11 M, 30 D

The table - function of Libre Office Calc is called in german DATUMDIF()

Get a calendar and count??





--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread John Landmesser

On 12.11.2013 21:40, John Landmesser wrote:


Which is correct?

Date1 := 29.2.2000
Date2 := 28.02.2001

Your function:
0 Y, 11 M, 27 D

Rxlib ( Jedi ) DateDiff:
0 Y, 11 M, 28 D

Libre Office Calc:
0 Y, 11 M, 30 D

The table - function of Libre Office Calc is called in german DATUMDIF()

Get a calendar and count??





--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus



*Jahr 2000* 

Januar  Tage
Februar 29  
März31  1. Monat
April   30  2. Monat
Mai 31  3. Monat
Juni30  4. Monat
Juli31  5. Monat
August  31  6. Monat
September   30  7. Monat
Oktober 31  8. Monat
November30  9. Monat
Dezember31  10. Monat



*Jahr 2001* 

Januar  31  11. Monat
Februar 28  


RxLib is correct !!!
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Michael Van Canneyt



On Tue, 12 Nov 2013, John Landmesser wrote:



Date1 := 29.2.2000
Date2 := 28.02.2001

Your function:
0 Y, 11 M, 27 D

Rxlib ( Jedi ) DateDiff:
0 Y, 11 M, 28 D

Libre Office Calc:
0 Y, 11 M, 30 D

The table - function of Libre Office Calc is called in german DATUMDIF()

Get a calendar and count??


Seeing this, I can't help but think that the approximation approach
may not be such a bad idea after all :D

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Bart
On 11/12/13, John Landmesser joh...@online.de wrote:

 On 12.11.2013 21:40, John Landmesser wrote:

 Which is correct?

 Date1 := 29.2.2000
 Date2 := 28.02.2001


I would actually say that in this particular case the diff is 1 Year...
(11 M + (28 days in feb in a non-leapyear = 1M) = 12M = 1 Y.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Bart
On 11/12/13, waldo kitty wkitt...@windstream.net wrote:

 you do not need any of the above if you change

  Days := (DaysPerMonth(M1, IsLeapYear(Y2)) - D1) + D2 ;

 to

Days := (DaysInAMonth(Y2,M1) - D1) + D2;


I did not know about DaysInAMonth.
I just went coding and created that function because I needed it.

I can see it uses the exact kind of logic I did...

 outside of this, what you came up with is almost exactly what i worked my
 way
 down to as i was working on my own solution... it took me a while and then
 when
 i saw your post, i was astonished at how the mind works at times :LOL:

Yes, nice.

Hope anyone actually can use this.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Can't enter negative values in to TFloatSpinEdit

2013-11-12 Thread Bart
Possibly related to http://bugs.freepascal.org/view.php?id=23266 ?
If not the same, please open a bugreport on the bugtracker.

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread Bart
On 11/12/13, John Landmesser joh...@online.de wrote:

 On 12.11.2013 21:40, John Landmesser wrote:

 Which is correct?

 Date1 := 29.2.2000
 Date2 := 28.02.2001

 Your function:
 0 Y, 11 M, 27 D

 Rxlib ( Jedi ) DateDiff:
 0 Y, 11 M, 28 D
[snip]

 RxLib is correct !!!


Fixed. (?)

procedure DateDiff(Date1, Date2: TDate; out Years, Months, Days: Word);
var
  Y1, Y2, M1, M2, D1, D2: word;

  procedure SwapDates(var D1, D2: TDate);
  var
TempD: TDate;
  begin
TempD := D1;
D1 := D2;
D2 := TempD;
  end;

begin
  if (Date1  Date2) then
SwapDates(Date1, Date2);
  Days := 0;
  Months := 0;
  Years := 0;
  DecodeDate(Date1, Y1, M1, D1);
  DecodeDate(Date2, Y2, M2, D2);
  Years := Y2 - Y1;
  if (M1  M2) or ((M1 = M2) and (D1  D2)) then Dec(Years);
  if (M1  M2) then Inc(M2, 12); //already adjusted Years in that case
  Months := M2 - M1;
  if (D2 = D1) then
Days := D2 - D1
  else
  begin
//writeln('D2  D1');
if (Months = 0) then
  Months := 11
else
  Dec(Months);
//writeln('DaysPerMonth(',M1,') = ',DaysPerMonth(M1, IsLeapYear(Y2)));
Days := (DaysPerMonth(M1, IsLeapYear(Y2)) - D1) + D2 ;
if (M1 = 2) and (M2 = 2) and IsLeapYear(Y1) then
begin
  Inc(Days);
end;
  end;
end;

Bart

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] DateDif function needed

2013-11-12 Thread waldo kitty

On 11/12/2013 3:40 PM, John Landmesser wrote:

On 12.11.2013 21:01, waldo kitty wrote:

[...]

Which is correct?

Date1 := 29.2.2000
Date2 := 28.02.2001

Your function:
0 Y, 11 M, 27 D

Rxlib ( Jedi ) DateDiff:
0 Y, 11 M, 28 D

Libre Office Calc:
0 Y, 11 M, 30 D

The table - function of Libre Office Calc is called in german DATUMDIF()

Get a calendar and count??


actually, i have in some cases... let's ask this question and see what your 
charts and routines return as the result... assuming your format is DD.MM....


Date1 := 01.01.2000
Date2 := 01.01.2000

should be 0 (zero), right?

then

Date1 := 01.01.2000
Date2 := 02.01.2000

should be 1 (one), right?

in this case, what i (and bart, too) wrote, we're not counting the starting day 
but we are counting the ending day... this rule stays in effect throughout the 
entire process... my head still aches from rummaging about doing this... it was 
good exercise and one i remember being given on a test many years back to 
determine one's coding level... at that time, the code was being done in dBase 
II/III/IV ;)


i will have to dig deeper and see what is crossing things up for count from 
29.02.2000 to 28.02.2001... i see bart has posted a fix which i have not yet had 
a chance to compare with my code or run thru the tests i included in my posting...


the real question is this:

  what do we count? the starting day, the ending day, both days or neither day?

then we have another question:

  is dayM in monthY a one month difference to dayM in monthX and
  monthZ? monthX, monthY, monthZ are any three consecutive months
  in linear order within one year or crossing two years

once the rules are chosen, then we have something to work with...

--
NOTE: No off-list assistance is given without prior approval.
  Please keep mailing list traffic on the list unless
  private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus