Lazarus
Programming => Packages and Libraries => KOL => Topic started by: JohnvdWaeter on March 04, 2008, 05:04:34 pm
-
Hi, using KOL-CE,
DateTimePicker1.Date:=date+10
does not seem to work
DateTimePicker1.DateTime:=date+10
does not seem to work either
How to?
tia!
John
-
Try this:
Put DateUtils in uses clauses, and after do:
DateTimePicker1.Date := IncDay(DateTimePicker1.Date, 10);
See too: IncMonth, IncYear...
I don't know if it's work with Time too...
-
Try this:
Put DateUtils in uses clauses, and after do:
DateTimePicker1.Date := IncDay(DateTimePicker1.Date, 10);
See too: IncMonth, IncYear...
I don't know if it's work with Time too...
Hi OnyxJr,
I don't think that is the problem. I think the problem is in the procedure DateTime2SystemTime in KOL.pas.
If I use this procedure to convert today (march 4, 2008),
I get ST.wYear=109, ST.wMonth=3 and ST.wDay=6
where it *should* read wYear=2008, wMonth=3 and wDay=4
That procedure is wrong, but I just cannot figure out why... have to do some more digging....
John
-
I think, in KOL.PAS, one line should be added in the procdurebody of DateTime2SystemTime:
begin
Days := Trunc( DateTime);
MSec := Round((DateTime - Days) * MSecsPerDay);
Days := Days+693594; // <-- add this line
Result := False;
......
It seems to work, but I'm not sure if this is the right way...
John
-
And in the last line of SystemTime2Datetime:
DateTime := I * 365 + I div 4 - I div 100 + I div 400 + _Day -693594 // <-- number added
+ (LongInt(wHour) * 3600000 + LongInt(wMinute) * 60000 + LongInt(wSecond) * 1000 + LongInt(wMilliSeconds)) / MSecsPerDay;
To get a proper value back from DateTimePicker1.Date
But again, I'm not sure... this might break other code? Could it be that the Date-property of TKolDateTimepicker actually is treated like TTimestamp instead of TDateTime?
-
And then, suddenly, the penny drops...
I had SysUtils in the uses-clause... mixing up different date and time types....
Time for a beer....