[Lazarus] Google Calendar API TEvent start or _end (TDatetime) question

Michael Van Canneyt michael at freepascal.org
Thu Jun 4 09:32:29 CEST 2020


Hello,

I'm afraid I am of no help here. I am not an expert on the google Calendar API...

What you can try to do is set the calendar configuration to your timezone
(Italy/Rome, I suppose) and do not provide any timezone information when you
create your items.

Michael.

On Thu, 4 Jun 2020, Francesco Sammarco wrote:

> if I change my code in this mode, and change Google Calendar configuration,
> with Greenwich meridian, I see correct result on Google Calendar. But I'm
> not on Greenwich meridian.
>
>
> I edited the demo calendar. I added a button and inside I put the following
> code.
>
> procedure TMainForm.Button1Click(Sender: TObject);
> var
>  Entry     : TEvent;
>  Insert    : TEvent;
>  start_e   : TEventDateTime;
>  end_e     : TEventDateTime;
> begin
>  if LBCalendars.ItemIndex<0 then
>    Exit;
>
>  start_e := TEventDateTime.Create();
>  end_e   := TEventDateTime.Create();
>
>  start_e.dateTime   := EncodeDateTime(2020,6,3,19,0,0,0);
>  start_e.timeZone   := 'Europe/London';
>  end_e.dateTime     := IncHour(start_e.dateTime,2);
>  end_e.timeZone     := 'Europe/London';
>
>  Entry := TEvent.Create();
>  Entry.summary               := 'My test';
>  Entry.description           := 'My test';
>  Entry.location              := 'My location';
>  Entry.start                 := start_e;
>  Entry._end                  := end_e;
>
>  Entry.guestsCanInviteOthers   := false;
>  Entry.guestsCanSeeOtherGuests := false;
>
>  Entry.colorId := '';
>
>  Insert := FCalendarAPI.EventsResource.Insert(FCurrentCalendar.id,Entry);
>
>  SaveRefreshToken;
>
>
>  Entry.Free;
>  Entry:=nil;
>
>  ShowMessage('Insert ' + Insert.id);
>
>  Insert.Free;
>  Insert:=nil;
> end;
>
> Il giorno mer 3 giu 2020 alle ore 15:59 Michael Van Canneyt <
> michael at freepascal.org> ha scritto:
>
>>
>>
>> On Wed, 3 Jun 2020, Francesco Sammarco wrote:
>>
>>> sorry and how do I set the date and time of the apartment ?!
>>
>> I would think this is sufficient:
>>
>>    Entry := FCalendarAPI.EventsResource.Get(CalendarFindedId, my_id_app);
>>    start_e := TEventDateTime.Create();
>>    end_e   := TEventDateTime.Create();
>>    start_e.dateTime   := data_appuntamento;
>>    start_e.timeZone   := 'Europe/Rome';
>>
>> Michael.
>>
>>>
>>> Il mer 3 giu 2020, 15:55 Michael Van Canneyt <michael at freepascal.org> ha
>>> scritto:
>>>
>>>>
>>>>
>>>> On Wed, 3 Jun 2020, Francesco Sammarco wrote:
>>>>
>>>>> sorry I don't understand, you say that just remove the lines where I
>>>>> specify the timezone ?!
>>>>
>>>> No, remove the
>>>>
>>>> start_e.dateTime   := LocalTimeToUniversal(start_e.dateTime);
>>>>
>>>> I think it is not necessary if you set the timezone.
>>>>
>>>> Michael.
>>>>
>>>>
>>>>>
>>>>> Il mer 3 giu 2020, 14:51 Michael Van Canneyt <michael at freepascal.org>
>> ha
>>>>> scritto:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, 3 Jun 2020, Francesco Sammarco via lazarus wrote:
>>>>>>
>>>>>>> Hi everyone, I have the following problem. I have a calendar
>> (Italian)
>>>> to
>>>>>>> sync with Google Calendar. With the following code I can work quite
>>>> well.
>>>>>>> If today (2020-06-03) I set a new appointment it is saved on google
>>>>>>> calendar on the right day and time, but if for example: always today
>>>> if I
>>>>>>> set an appointment for December 10, 2020 at 9 am, I find myself there
>>>>>>> appointment set on the right day but at 8 am. (So an hour behind) I
>>>> think
>>>>>>> it's due to the change between sunlight and daylight. Can anyone
>>>> explain
>>>>>> to
>>>>>>> me how to solve the problem?
>>>>>>>
>>>>>>> Thank you
>>>>>>> XinYiMan
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> var
>>>>>>>   start_e  : TEventDateTime;
>>>>>>>   end_e    : TEventDateTime;
>>>>>>>   Entry    : TEvent;
>>>>>>> begin
>>>>>>>            Entry := FCalendarAPI.EventsResource.Get(CalendarFindedId,
>>>>>>> my_id_app);
>>>>>>>
>>>>>>>                     start_e := TEventDateTime.Create();
>>>>>>>                     end_e   := TEventDateTime.Create();
>>>>>>>
>>>>>>>                     start_e.dateTime   := data_appuntamento;
>>>>>>>                     start_e.dateTime   :=
>>>>>>> LocalTimeToUniversal(start_e.dateTime);
>>>>>>>                     start_e.timeZone   := 'Europe/Rome';
>>>>>>
>>>>>> If you set the timzeone explicitly, I don't think you must do a
>>>>>> LocalTimeToUniversal,
>>>>>> I think the timezone is then automatically taken into account. As I
>>>>>> understand it you specify the timezone in dateTime or you set it in
>> the
>>>>>> timezone.
>>>>>>
>>>>>> Michael.
>>>>>>
>>>>>
>>>>
>>>
>>
>


More information about the lazarus mailing list