<div dir="ltr">I tested this way. But not run correctly. Who is the Google API creator?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 4 giu 2020 alle ore 09:32 Michael Van Canneyt <<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hello,<br>
<br>
I'm afraid I am of no help here. I am not an expert on the google Calendar API...<br>
<br>
What you can try to do is set the calendar configuration to your timezone<br>
(Italy/Rome, I suppose) and do not provide any timezone information when you<br>
create your items.<br>
<br>
Michael.<br>
<br>
On Thu, 4 Jun 2020, Francesco Sammarco wrote:<br>
<br>
> if I change my code in this mode, and change Google Calendar configuration,<br>
> with Greenwich meridian, I see correct result on Google Calendar. But I'm<br>
> not on Greenwich meridian.<br>
><br>
><br>
> I edited the demo calendar. I added a button and inside I put the following<br>
> code.<br>
><br>
> procedure TMainForm.Button1Click(Sender: TObject);<br>
> var<br>
>  Entry     : TEvent;<br>
>  Insert    : TEvent;<br>
>  start_e   : TEventDateTime;<br>
>  end_e     : TEventDateTime;<br>
> begin<br>
>  if LBCalendars.ItemIndex<0 then<br>
>    Exit;<br>
><br>
>  start_e := TEventDateTime.Create();<br>
>  end_e   := TEventDateTime.Create();<br>
><br>
>  start_e.dateTime   := EncodeDateTime(2020,6,3,19,0,0,0);<br>
>  start_e.timeZone   := 'Europe/London';<br>
>  end_e.dateTime     := IncHour(start_e.dateTime,2);<br>
>  end_e.timeZone     := 'Europe/London';<br>
><br>
>  Entry := TEvent.Create();<br>
>  Entry.summary               := 'My test';<br>
>  Entry.description           := 'My test';<br>
>  Entry.location              := 'My location';<br>
>  Entry.start                 := start_e;<br>
>  Entry._end                  := end_e;<br>
><br>
>  Entry.guestsCanInviteOthers   := false;<br>
>  Entry.guestsCanSeeOtherGuests := false;<br>
><br>
>  Entry.colorId := '';<br>
><br>
>  Insert := FCalendarAPI.EventsResource.Insert(FCurrentCalendar.id,Entry);<br>
><br>
>  SaveRefreshToken;<br>
><br>
><br>
>  Entry.Free;<br>
>  Entry:=nil;<br>
><br>
>  ShowMessage('Insert ' + Insert.id);<br>
><br>
>  Insert.Free;<br>
>  Insert:=nil;<br>
> end;<br>
><br>
> Il giorno mer 3 giu 2020 alle ore 15:59 Michael Van Canneyt <<br>
> <a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>> ha scritto:<br>
><br>
>><br>
>><br>
>> On Wed, 3 Jun 2020, Francesco Sammarco wrote:<br>
>><br>
>>> sorry and how do I set the date and time of the apartment ?!<br>
>><br>
>> I would think this is sufficient:<br>
>><br>
>>    Entry := FCalendarAPI.EventsResource.Get(CalendarFindedId, my_id_app);<br>
>>    start_e := TEventDateTime.Create();<br>
>>    end_e   := TEventDateTime.Create();<br>
>>    start_e.dateTime   := data_appuntamento;<br>
>>    start_e.timeZone   := 'Europe/Rome';<br>
>><br>
>> Michael.<br>
>><br>
>>><br>
>>> Il mer 3 giu 2020, 15:55 Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>> ha<br>
>>> scritto:<br>
>>><br>
>>>><br>
>>>><br>
>>>> On Wed, 3 Jun 2020, Francesco Sammarco wrote:<br>
>>>><br>
>>>>> sorry I don't understand, you say that just remove the lines where I<br>
>>>>> specify the timezone ?!<br>
>>>><br>
>>>> No, remove the<br>
>>>><br>
>>>> start_e.dateTime   := LocalTimeToUniversal(start_e.dateTime);<br>
>>>><br>
>>>> I think it is not necessary if you set the timezone.<br>
>>>><br>
>>>> Michael.<br>
>>>><br>
>>>><br>
>>>>><br>
>>>>> Il mer 3 giu 2020, 14:51 Michael Van Canneyt <<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>><br>
>> ha<br>
>>>>> scritto:<br>
>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> On Wed, 3 Jun 2020, Francesco Sammarco via lazarus wrote:<br>
>>>>>><br>
>>>>>>> Hi everyone, I have the following problem. I have a calendar<br>
>> (Italian)<br>
>>>> to<br>
>>>>>>> sync with Google Calendar. With the following code I can work quite<br>
>>>> well.<br>
>>>>>>> If today (2020-06-03) I set a new appointment it is saved on google<br>
>>>>>>> calendar on the right day and time, but if for example: always today<br>
>>>> if I<br>
>>>>>>> set an appointment for December 10, 2020 at 9 am, I find myself there<br>
>>>>>>> appointment set on the right day but at 8 am. (So an hour behind) I<br>
>>>> think<br>
>>>>>>> it's due to the change between sunlight and daylight. Can anyone<br>
>>>> explain<br>
>>>>>> to<br>
>>>>>>> me how to solve the problem?<br>
>>>>>>><br>
>>>>>>> Thank you<br>
>>>>>>> XinYiMan<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> var<br>
>>>>>>>   start_e  : TEventDateTime;<br>
>>>>>>>   end_e    : TEventDateTime;<br>
>>>>>>>   Entry    : TEvent;<br>
>>>>>>> begin<br>
>>>>>>>            Entry := FCalendarAPI.EventsResource.Get(CalendarFindedId,<br>
>>>>>>> my_id_app);<br>
>>>>>>><br>
>>>>>>>                     start_e := TEventDateTime.Create();<br>
>>>>>>>                     end_e   := TEventDateTime.Create();<br>
>>>>>>><br>
>>>>>>>                     start_e.dateTime   := data_appuntamento;<br>
>>>>>>>                     start_e.dateTime   :=<br>
>>>>>>> LocalTimeToUniversal(start_e.dateTime);<br>
>>>>>>>                     start_e.timeZone   := 'Europe/Rome';<br>
>>>>>><br>
>>>>>> If you set the timzeone explicitly, I don't think you must do a<br>
>>>>>> LocalTimeToUniversal,<br>
>>>>>> I think the timezone is then automatically taken into account. As I<br>
>>>>>> understand it you specify the timezone in dateTime or you set it in<br>
>> the<br>
>>>>>> timezone.<br>
>>>>>><br>
>>>>>> Michael.<br>
>>>>>><br>
>>>>><br>
>>>><br>
>>><br>
>><br>
><br>
</blockquote></div>