Planner timezone question

Hi,

I’m using a TMSFNCPlanner component that I hook to a TMSFNCPlannerDatabaseAdapter which is fed from a REST service.
Everything is fine, I match the Adapter Item.DBKey | EndTime | StartTime | Title | Text fields to my own data, and everything is correctly displayed on the Planner…except the times which come in UTC times.

Is there a way to tell the Planner to use UTC+1 or set a TimeZone so it adjusts correctly, like UTC-4 or UTC+6?
I’d like to avoid having to manually add 1 hour or any TimeZone offset to all my data before hooking it to the Planner.

Thanks for any clue if someone already faced that kind of trouble.

Steve J

Hi,

In the OnFieldsToItem, you could overwrite the start & end time with the following code:

procedure TForm1.TMSFNCPlannerDatabaseAdapter1FieldsToItem(Sender: TObject;
  AFields: TFields; AItem: TTMSFNCPlannerItem);
begin
  AItem.StartTime := IncHour(AFields.FieldByName('StartTime').AsDateTime, 1);
  AItem.EndTime := IncHour(AFields.FieldByName('EndTime').AsDateTime, 1);
end;

This is for read, and the sample increases the date/time coming from the database with one hour just as an example.

If you want to write back to the database. You’ll have to do the opposite:

procedure TForm1.TMSFNCPlannerDatabaseAdapter1ItemToFields(Sender: TObject;
  AItem: TTMSFNCPlannerItem; AFields: TFields);
begin
  AFields.FieldByName('StartTime').AsDateTime := IncHour(AItem.StartTime, -1);
  AFields.FieldByName('EndTime').AsDateTime := IncHour(AItem.EndTime, -1);
end;
1 Like

Wonderful,

That’s what I needed. I actually add or subtract the local device timezone and it works accordingly now.

Now that I understand the ItemToFiels and FieldsToItem events, I also can use them to customize all the colors, etc… from each Item.

Thanks a lot for your help

Steve

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.