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

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
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';

                     end_e.dateTime     := IncMinute(LocalTimeToUniversal(data_appuntamento),15);
                     end_e.timeZone     := 'Europe/Rome';

                     Entry.start                 := start_e;
                     Entry._end                  := end_e;




--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list


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.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
sorry I don't understand, you say that just remove the lines where I specify the timezone ?!

Il mer 3 giu 2020, 14:51 Michael Van Canneyt <[hidden email]> 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.

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list


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 <[hidden email]> 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.
>>
>
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
sorry and how do I set the date and time of the apartment ?!

Il mer 3 giu 2020, 15:55 Michael Van Canneyt <[hidden email]> 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 <[hidden email]> 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.
>>
>

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list


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 <[hidden email]> 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 <[hidden email]> 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.
>>>>
>>>
>>
>
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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.
>>>>
>>>
>>
>

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list

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 <
> [hidden email]> 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 <[hidden email]> 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 <[hidden email]>
>> 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.
>>>>>>
>>>>>
>>>>
>>>
>>
>
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
I tested this way. But not run correctly. Who is the Google API creator?

Il giorno gio 4 giu 2020 alle ore 09:32 Michael Van Canneyt <[hidden email]> ha scritto:

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 <
> [hidden email]> 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 <[hidden email]> 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 <[hidden email]>
>> 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.
>>>>>>
>>>>>
>>>>
>>>
>>
>

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list


On Thu, 4 Jun 2020, Francesco Sammarco wrote:

> I tested this way. But not run correctly. Who is the Google API creator?

Google of course.

This is not a problem of the FPC API.
The API just tranfers data in a typesafe manner:
All it does is give you a way to create and interpret the JSON in a typesafe manner.

It does not know or care how Google interprets the data you send, this you
need to ask on Google forums or stackoverflow or somesuch.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
If anyone cares I think I have found a working way. Basically I do the insertion or updating of the appointment. The API returns the content of the newly updated or inserted appointment, I compare the hours contained with the hours I wanted to set. I calculate the difference and apply it. I make a second update with the correct date / time. I know it's not elegant, but for the moment it seems the only working way.

Il giorno gio 4 giu 2020 alle ore 10:13 Michael Van Canneyt via lazarus <[hidden email]> ha scritto:


On Thu, 4 Jun 2020, Francesco Sammarco wrote:

> I tested this way. But not run correctly. Who is the Google API creator?

Google of course.

This is not a problem of the FPC API.
The API just tranfers data in a typesafe manner:
All it does is give you a way to create and interpret the JSON in a typesafe manner.

It does not know or care how Google interprets the data you send, this you
need to ask on Google forums or stackoverflow or somesuch.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
> If anyone cares I think I have found a working way. Basically I do the insertion
> or updating of the appointment. The API returns the content of the newly updated
> or inserted appointment, I compare the hours contained with the hours I wanted
> to set. I calculate the difference and apply it. I make a second update with the
> correct date / time. I know it's not elegant, but for the moment it seems the
> only working way.


can you not determine if your desired time is in the daylight saving tim eperiod
and adjust it as needed before you do the first posting to the calendar? i was
going to suggest that yesterday when i first read of your plight but i wanted to
wait and see what others might suggest...

so basically:

1. you decide your time and date...
2. check if it is within the daylight saving time period for your area...
2a. if #2 is yes, adjust the time as needed...
2b. if #2 is no, leave the time as originally set...
3. publish the appointment/event in the calendar...
4. done ;)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
Of course, it's just not the idea of how to check if the time falls in daylight saving time or not.

Il giorno gio 4 giu 2020 alle ore 17:24 wkitty42--- via lazarus <[hidden email]> ha scritto:
On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
> If anyone cares I think I have found a working way. Basically I do the insertion
> or updating of the appointment. The API returns the content of the newly updated
> or inserted appointment, I compare the hours contained with the hours I wanted
> to set. I calculate the difference and apply it. I make a second update with the
> correct date / time. I know it's not elegant, but for the moment it seems the
> only working way.


can you not determine if your desired time is in the daylight saving tim eperiod
and adjust it as needed before you do the first posting to the calendar? i was
going to suggest that yesterday when i first read of your plight but i wanted to
wait and see what others might suggest...

so basically:

1. you decide your time and date...
2. check if it is within the daylight saving time period for your area...
2a. if #2 is yes, adjust the time as needed...
2b. if #2 is no, leave the time as originally set...
3. publish the appointment/event in the calendar...
4. done ;)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
On 6/5/20 2:04 AM, Francesco Sammarco wrote:
> Of course, it's just not the idea of how to check if the time falls in daylight
> saving time or not.


why not? that is the problem and apparently the API and/or backend code at
google don't handle it so the creator of the event/appointment must...


> Il giorno gio 4 giu 2020 alle ore 17:24 wkitty42--- via lazarus
> <[hidden email] <mailto:[hidden email]>> ha scritto:
>
>     On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
>      > If anyone cares I think I have found a working way. Basically I do the
>     insertion
>      > or updating of the appointment. The API returns the content of the newly
>     updated
>      > or inserted appointment, I compare the hours contained with the hours I
>     wanted
>      > to set. I calculate the difference and apply it. I make a second update
>     with the
>      > correct date / time. I know it's not elegant, but for the moment it seems
>     the
>      > only working way.
>
>
>     can you not determine if your desired time is in the daylight saving tim
>     eperiod
>     and adjust it as needed before you do the first posting to the calendar? i was
>     going to suggest that yesterday when i first read of your plight but i
>     wanted to
>     wait and see what others might suggest...
>
>     so basically:
>
>     1. you decide your time and date...
>     2. check if it is within the daylight saving time period for your area...
>     2a. if #2 is yes, adjust the time as needed...
>     2b. if #2 is no, leave the time as originally set...
>     3. publish the appointment/event in the calendar...
>     4. done ;)
>
>
>     --
>        NOTE: No off-list assistance is given without prior approval.
>              *Please keep mailing list traffic on the list where it belongs!*
>     --
>     _______________________________________________
>     lazarus mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.lazarus-ide.org/listinfo/lazarus
>


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
Ok. But not so how to do it. Is there an example?

Il giorno ven 5 giu 2020 alle ore 13:54 wkitty42--- via lazarus <[hidden email]> ha scritto:
On 6/5/20 2:04 AM, Francesco Sammarco wrote:
> Of course, it's just not the idea of how to check if the time falls in daylight
> saving time or not.


why not? that is the problem and apparently the API and/or backend code at
google don't handle it so the creator of the event/appointment must...


> Il giorno gio 4 giu 2020 alle ore 17:24 wkitty42--- via lazarus
> <[hidden email] <mailto:[hidden email]>> ha scritto:
>
>     On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
>      > If anyone cares I think I have found a working way. Basically I do the
>     insertion
>      > or updating of the appointment. The API returns the content of the newly
>     updated
>      > or inserted appointment, I compare the hours contained with the hours I
>     wanted
>      > to set. I calculate the difference and apply it. I make a second update
>     with the
>      > correct date / time. I know it's not elegant, but for the moment it seems
>     the
>      > only working way.
>
>
>     can you not determine if your desired time is in the daylight saving tim
>     eperiod
>     and adjust it as needed before you do the first posting to the calendar? i was
>     going to suggest that yesterday when i first read of your plight but i
>     wanted to
>     wait and see what others might suggest...
>
>     so basically:
>
>     1. you decide your time and date...
>     2. check if it is within the daylight saving time period for your area...
>     2a. if #2 is yes, adjust the time as needed...
>     2b. if #2 is no, leave the time as originally set...
>     3. publish the appointment/event in the calendar...
>     4. done ;)
>
>
>     --
>        NOTE: No off-list assistance is given without prior approval.
>              *Please keep mailing list traffic on the list where it belongs!*
>     --
>     _______________________________________________
>     lazarus mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.lazarus-ide.org/listinfo/lazarus
>


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
As Example for Germany:










Am 05.06.20 um 14:00 schrieb Francesco Sammarco via lazarus:
Ok. But not so how to do it. Is there an example?

Il giorno ven 5 giu 2020 alle ore 13:54 wkitty42--- via lazarus <[hidden email]> ha scritto:
On 6/5/20 2:04 AM, Francesco Sammarco wrote:
> Of course, it's just not the idea of how to check if the time falls in daylight
> saving time or not.


why not? that is the problem and apparently the API and/or backend code at
google don't handle it so the creator of the event/appointment must...


> Il giorno gio 4 giu 2020 alle ore 17:24 wkitty42--- via lazarus
> <[hidden email] <mailto:[hidden email]>> ha scritto:
>
>     On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
>      > If anyone cares I think I have found a working way. Basically I do the
>     insertion
>      > or updating of the appointment. The API returns the content of the newly
>     updated
>      > or inserted appointment, I compare the hours contained with the hours I
>     wanted
>      > to set. I calculate the difference and apply it. I make a second update
>     with the
>      > correct date / time. I know it's not elegant, but for the moment it seems
>     the
>      > only working way.
>
>
>     can you not determine if your desired time is in the daylight saving tim
>     eperiod
>     and adjust it as needed before you do the first posting to the calendar? i was
>     going to suggest that yesterday when i first read of your plight but i
>     wanted to
>     wait and see what others might suggest...
>
>     so basically:
>
>     1. you decide your time and date...
>     2. check if it is within the daylight saving time period for your area...
>     2a. if #2 is yes, adjust the time as needed...
>     2b. if #2 is no, leave the time as originally set...
>     3. publish the appointment/event in the calendar...
>     4. done ;)
>
>
>     --
>        NOTE: No off-list assistance is given without prior approval.
>              *Please keep mailing list traffic on the list where it belongs!*
>     --
>     _______________________________________________
>     lazarus mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.lazarus-ide.org/listinfo/lazarus
>


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus



--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
Sorry but I knew it is not wise to implement it like this, because being a political choice it can change from year to year. But if there is no alternative, I will proceed on that road too.

Il giorno ven 5 giu 2020 alle ore 14:04 John Landmesser via lazarus <[hidden email]> ha scritto:
As Example for Germany:










Am 05.06.20 um 14:00 schrieb Francesco Sammarco via lazarus:
Ok. But not so how to do it. Is there an example?

Il giorno ven 5 giu 2020 alle ore 13:54 wkitty42--- via lazarus <[hidden email]> ha scritto:
On 6/5/20 2:04 AM, Francesco Sammarco wrote:
> Of course, it's just not the idea of how to check if the time falls in daylight
> saving time or not.


why not? that is the problem and apparently the API and/or backend code at
google don't handle it so the creator of the event/appointment must...


> Il giorno gio 4 giu 2020 alle ore 17:24 wkitty42--- via lazarus
> <[hidden email] <mailto:[hidden email]>> ha scritto:
>
>     On 6/4/20 10:37 AM, Francesco Sammarco via lazarus wrote:
>      > If anyone cares I think I have found a working way. Basically I do the
>     insertion
>      > or updating of the appointment. The API returns the content of the newly
>     updated
>      > or inserted appointment, I compare the hours contained with the hours I
>     wanted
>      > to set. I calculate the difference and apply it. I make a second update
>     with the
>      > correct date / time. I know it's not elegant, but for the moment it seems
>     the
>      > only working way.
>
>
>     can you not determine if your desired time is in the daylight saving tim
>     eperiod
>     and adjust it as needed before you do the first posting to the calendar? i was
>     going to suggest that yesterday when i first read of your plight but i
>     wanted to
>     wait and see what others might suggest...
>
>     so basically:
>
>     1. you decide your time and date...
>     2. check if it is within the daylight saving time period for your area...
>     2a. if #2 is yes, adjust the time as needed...
>     2b. if #2 is no, leave the time as originally set...
>     3. publish the appointment/event in the calendar...
>     4. done ;)
>
>
>     --
>        NOTE: No off-list assistance is given without prior approval.
>              *Please keep mailing list traffic on the list where it belongs!*
>     --
>     _______________________________________________
>     lazarus mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.lazarus-ide.org/listinfo/lazarus
>


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list where it belongs!*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

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

Free Pascal - Lazarus mailing list
AFAIK, from 2010, in Italy dayligth starts on last sunday of march and
ends the last sunday of october

nomorelogic


Il 05/06/20 15:57, Francesco Sammarco via lazarus ha scritto:

> Sorry but I knew it is not wise to implement it like this, because
> being a political choice it can change from year to year. But if there
> is no alternative, I will proceed on that road too.
>
> Il giorno ven 5 giu 2020 alle ore 14:04 John Landmesser via lazarus
> <[hidden email] <mailto:[hidden email]>>
> ha scritto:
>
>     As Example for Germany:
>
>     https://wiki.freepascal.org/Daylight_saving_time/de
>

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus