Forum > KOL

How to set a date in TKoldateTimePicker?

(1/2) > >>

JohnvdWaeter:
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

OnixJr:
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...

JohnvdWaeter:

--- Quote from: "OnixJr" ---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...
--- End quote ---


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

JohnvdWaeter:
I think, in KOL.PAS, one line should be added in the procdurebody of DateTime2SystemTime:


--- Code: ---
begin
  Days := Trunc( DateTime);
  MSec := Round((DateTime - Days) * MSecsPerDay);
 
  Days := Days+693594; // <-- add this line

  Result := False;  
  ......


--- End code ---


It seems to work, but I'm not sure if this is the right way...

John

JohnvdWaeter:
And in the last line of SystemTime2Datetime:


--- Code: ---
   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;


--- End code ---


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?

Navigation

[0] Message Index

[#] Next page

Go to full version