IndexToTime not working as expected


In a planner (with type=Day or Week) the indextotime function is always returning datetime = Sat 30-Dec-1899 00:00. can you assist please?

  procedure TfraDiary.DoOnplannerItemMove(Sender: TObject; Item: TPlannerItem; FromBegin, FromEnd, FromPos, ToBegin, ToEnd, ToPos: Integer);
      dtFm : TdateTime;            
      dtTo : TdateTime;            
      dt   : TdateTime;            
      s1   : string;
      s2   : string;
      dtFm := planner.IndexToTime(FromEnd);
      s1  := Formatdatetime( 'ddd dd-mmm-yyyy hh:mm', dtFm );
      dtTo := planner.IndexToTime(Toend);
      s2  := Formatdatetime( 'ddd dd-mmm-yyyy hh:mm', dtTo );

      // example of status msg:
      // [From B_55 E_58 P_0][To B_54 E_57 P_0] Sat 30-Dec-1899 00:00 to Sat 30-Dec-1899 00:00'

      Gapp.statusMsg := Format( '[From B_%d E_%d P_%d][To B_%d E_%d P_%d] %s to %s', 
       [FromBegin, FromEnd, FromPos, ToBegin, ToEnd,ToPos, s1, s2]);

Update: I used CellToAbsTime() instead and it works fine.

(code modified from  TCustomPlanner.SelectionToAbsTime(var dtStart, dtEnd: TDateTime);)

      with Planner do
         CellToAbsTime( FromEnd, dFm, dTo);

         if (Mode.PlannerType in [plDay, plHalfDayPeriod]) then
            CellToAbsTime( ToEnd, dTo, dt)
            CellToAbsTime( ToEnd- 1, dTo, dt);

         if (Mode.PlannerType = plDay) and (FromEnd <> ToEnd) and (dTo = dFm) then
            dTo := dTo + 1;
         s1  := Formatdatetime( 'ddd dd-mmm-yyyy hh:mm', dFm );
         s2  := Formatdatetime( 'ddd dd-mmm-yyyy hh:mm', dTo );
         Gapp.statusMsg := Format( '[From B_%d E_%d P_%d][To B_%d E_%d P_%d] %s to %s', [ FromBegin, FromEnd, FromPos, ToBegin, ToEnd,ToPos, s1, s2]);

IndexToTime() is the function to use when Planner.Mode.PlannerType = plCustomList.

Thanks Bruno.

Is there any function (similar to CellToAbsTime()) that takes account of changes in column position when type=week?

Looks like     PosToDay(Pos: Integer): TDateTime; is the one

Having a bit of a problem: 

               planner.Positions := 5;    // (mon-fri)             
               planner.Mode.PeriodStartDate := FPeriodStart; (mon)

dFm := PosToDay(FromPos); 
         dto := PosToDay(ToPos)  ; 

return sunday instead of fri. is there another property I need to set ?

Got it - TPlanner.Mode.WeekStart