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

2020-06-04 Thread Francesco Sammarco via lazarus
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 <
lazarus@lists.lazarus-ide.org> 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
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Ignore or Deinstall-Reinstall?

2020-06-04 Thread Ralf Quint via lazarus

On 6/4/2020 9:13 AM, Martin Frb via lazarus wrote:


The error is about macros in the source editor.
You can use normal macros, but not macros with Pascalscript.
I got the same error message when I re-installed Lazarus 2.0.8 on macOS 
(High Sierra)


See 
https://forum.lazarus.freepascal.org/index.php/topic,50059.msg364619.html#msg364619


Will check this out if this applies in my case too

Ralf



--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Ignore or Deinstall-Reinstall?

2020-06-04 Thread Joe via lazarus

Am 04.06.2020 um 18:13 schrieb Martin Frb via lazarus:

On 04/06/2020 18:08, Joe via lazarus wrote:
During the first run of Lazarus after the installation of the current 
version of Raspios on a Pi B 8GB it get this error message:


"The package EditorMascroScript (pascal script macros) has detected a 
problem and was deactivated. The package failed its self test with 
the message "Replace All [Exp: True/Got False]".


After restart of Lazarus, this message is not shown again, and the 
Pascal Script Tab is visible.


Can I safely ignore this error message or should I deinstall and 
install this package?


The current Raspios Distro contains Lazarus 2.0.0+dfsg-2, SVN 
Revision Debian package 2.0.0 arm-linux-gtk2.




I am not sure that will work on arm (or whatever cpu you have). 
Pascalscript has some arm support, but not sure it is good enough.


The error is about macros in the source editor.
You can use normal macros, but not macros with Pascalscript.

See 
https://forum.lazarus.freepascal.org/index.php/topic,50059.msg364619.html#msg364619


Thank you, Martin.
Regards -- Joe
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Ignore or Deinstall-Reinstall?

2020-06-04 Thread Martin Frb via lazarus

On 04/06/2020 18:08, Joe via lazarus wrote:
During the first run of Lazarus after the installation of the current 
version of Raspios on a Pi B 8GB it get this error message:


"The package EditorMascroScript (pascal script macros) has detected a 
problem and was deactivated. The package failed its self test with the 
message "Replace All [Exp: True/Got False]".


After restart of Lazarus, this message is not shown again, and the 
Pascal Script Tab is visible.


Can I safely ignore this error message or should I deinstall and 
install this package?


The current Raspios Distro contains Lazarus 2.0.0+dfsg-2, SVN Revision 
Debian package 2.0.0 arm-linux-gtk2.




I am not sure that will work on arm (or whatever cpu you have). 
Pascalscript has some arm support, but not sure it is good enough.


The error is about macros in the source editor.
You can use normal macros, but not macros with Pascalscript.

See 
https://forum.lazarus.freepascal.org/index.php/topic,50059.msg364619.html#msg364619

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Ignore or Deinstall-Reinstall?

2020-06-04 Thread Joe via lazarus
During the first run of Lazarus after the installation of the current 
version of Raspios on a Pi B 8GB it get this error message:


"The package EditorMascroScript (pascal script macros) has detected a 
problem and was deactivated. The package failed its self test with the 
message "Replace All [Exp: True/Got False]".


After restart of Lazarus, this message is not shown again, and the 
Pascal Script Tab is visible.


Can I safely ignore this error message or should I deinstall and install 
this package?


The current Raspios Distro contains Lazarus 2.0.0+dfsg-2, SVN Revision 
Debian package 2.0.0 arm-linux-gtk2.


Regards - Joe

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


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

2020-06-04 Thread wkitty42--- via lazarus

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
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Luca Olivetti via lazarus

El 4/6/20 a les 17:07, Sven Barth ha escrit:



TThread.Synchronize needs a TThread as the first parameter.
This is my work in progress


The thread parameter can be Nil. TThread will then use the CurrentThread 
threadvar and failing that it can also work without any thread object.


In fact it is safer not to pass a thread.


Oh, I didn't know that. Thank you.

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Sven Barth via lazarus
Luca Olivetti via lazarus  schrieb am Do.,
4. Juni 2020, 15:51:

> El 4/6/20 a les 15:37, Michael Van Canneyt via lazarus ha escrit:
> >
> >
> > On Thu, 4 Jun 2020, Luca Olivetti via lazarus wrote:
> >
> >>>  FServer.Port:=8080;
> >>>  FServer.Threaded:=true;
> >>>  FServer.Run;
> >>>except
> >>>  on E:Exception do
> >>>  begin
> >>>writeln(E.Message);
> >>>sleep(1000);
> >>>FServer.Free;
> >>>  end;
> >>>end;
> >>
> >> Oh, and I had to do some more overriding so that the response could
> >> have a reference to the calling thread (needed if I want to use
> >> synchronize).
> >
> > That seems a bit strange, since you can do synchronize without needing
> > access to the thread object using a class method of TThread ?
>
> TThread.Synchronize needs a TThread as the first parameter.
> This is my work in progress
>

The thread parameter can be Nil. TThread will then use the CurrentThread
threadvar and failing that it can also work without any thread object.

In fact it is safer not to pass a thread.

Regards,
Sven

>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


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

2020-06-04 Thread Francesco Sammarco via lazarus
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 <
lazarus@lists.lazarus-ide.org> 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
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Luca Olivetti via lazarus

El 4/6/20 a les 15:37, Michael Van Canneyt via lazarus ha escrit:



On Thu, 4 Jun 2020, Luca Olivetti via lazarus wrote:


 FServer.Port:=8080;
 FServer.Threaded:=true;
 FServer.Run;
   except
 on E:Exception do
 begin
   writeln(E.Message);
   sleep(1000);
   FServer.Free;
 end;
   end;


Oh, and I had to do some more overriding so that the response could 
have a reference to the calling thread (needed if I want to use 
synchronize).


That seems a bit strange, since you can do synchronize without needing
access to the thread object using a class method of TThread ?


TThread.Synchronize needs a TThread as the first parameter.
This is my work in progress

https://paste.ubuntu.com/p/cKdQmCQw7p/

The main difference from the previous pastebin is that I subclass 
TFPHTTPConnection to add a TThread field and override the 
CreateConnectionThread to add the thread reference to the connection.
And I added more parameters to the server thread to pass on events from 
the main thread.



Tlogger is a simple class defined in utils.pas (not included) that logs 
messages.


The idea is that every time a new sse connection comes in, I notify the 
main thread (not yet implemented), then in DoSendConnect I enter a loop 
where I get the data from the main thread (with synchronize) then wait 
on an event (that the main thread signals every time the data changes). 
If there is no new data, every 10 seconds I send an empty message as a 
keepalive.



So, I need synchronize:

 - to notify a new connection
 - to get data for that connection
 - to notify that the connection terminated

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Michael Van Canneyt via lazarus



On Thu, 4 Jun 2020, Luca Olivetti via lazarus wrote:


     FServer.Port:=8080;
     FServer.Threaded:=true;
     FServer.Run;
   except
     on E:Exception do
     begin
   writeln(E.Message);
   sleep(1000);
   FServer.Free;
     end;
   end;


Oh, and I had to do some more overriding so that the response could have 
a reference to the calling thread (needed if I want to use synchronize).


That seems a bit strange, since you can do synchronize without needing
access to the thread object using a class method of TThread ?

Can you send me the changes you had to do ?

Michael.-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Luca Olivetti via lazarus

El 4/6/20 a les 12:04, Luca Olivetti via lazarus ha escrit:

El 4/6/20 a les 11:48, Michael Van Canneyt ha escrit:


It turns out I can with some careful, or reckless ;-),  overriding.

https://paste.ubuntu.com/p/CdHfc7BTHB/


Haha, very nice job :-)

I'll see if I can integrate this in the HTTPServer request/response.

It won't work in fastCGI/CGI of course, but if we can make it 
available in a

http application, why not...



I think that approach (take over the socket from the response) could be 
useful in more cases, e.g. streaming content, websockets, etc.
As you say it has to be a stand-alone/embedded server and probably it 
only works when it's threaded (due to the connection being kept active 
for an indeterminate time), but that's better than nothing.


Now, I have another problem: if the server cannot bind to the port it 
throws an exception, but then I cannot try again, I have to destroy and 
recreate the server, e.g. this doesn't work (the second call to 
FServer.Run return immediately):



   FServer:=TSseServerHandler.Create(nil);
   FServer.Port:=8080;
   FServer.Threaded:=true;
   while not terminated do
   try
     FServer.Run;
   except
     on E:Exception do
     begin
   writeln(E.Message);
   sleep(1000);
   FServer.Terminate;
     end;
   end;


this does (but I don't like it)

   while not terminated do
   try
     FServer:=TSseServerHandler.Create(nil);
     FServer.Port:=8080;
     FServer.Threaded:=true;
     FServer.Run;
   except
     on E:Exception do
     begin
   writeln(E.Message);
   sleep(1000);
   FServer.Free;
     end;
   end;


Oh, and I had to do some more overriding so that the response could have 
a reference to the calling thread (needed if I want to use synchronize).


Bye

--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Luca Olivetti via lazarus

El 4/6/20 a les 11:48, Michael Van Canneyt ha escrit:


It turns out I can with some careful, or reckless ;-),  overriding.

https://paste.ubuntu.com/p/CdHfc7BTHB/


Haha, very nice job :-)

I'll see if I can integrate this in the HTTPServer request/response.

It won't work in fastCGI/CGI of course, but if we can make it available 
in a

http application, why not...



I think that approach (take over the socket from the response) could be 
useful in more cases, e.g. streaming content, websockets, etc.
As you say it has to be a stand-alone/embedded server and probably it 
only works when it's threaded (due to the connection being kept active 
for an indeterminate time), but that's better than nothing.


Now, I have another problem: if the server cannot bind to the port it 
throws an exception, but then I cannot try again, I have to destroy and 
recreate the server, e.g. this doesn't work (the second call to 
FServer.Run return immediately):



  FServer:=TSseServerHandler.Create(nil);
  FServer.Port:=8080;
  FServer.Threaded:=true;
  while not terminated do
  try
FServer.Run;
  except
on E:Exception do
begin
  writeln(E.Message);
  sleep(1000);
  FServer.Terminate;
end;
  end;


this does (but I don't like it)

  while not terminated do
  try
FServer:=TSseServerHandler.Create(nil);
FServer.Port:=8080;
FServer.Threaded:=true;
FServer.Run;
  except
on E:Exception do
begin
  writeln(E.Message);
  sleep(1000);
  FServer.Free;
end;
  end;


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Michael Van Canneyt via lazarus



On Thu, 4 Jun 2020, Luca Olivetti via lazarus wrote:


El 3/6/20 a les 15:54, Michael Van Canneyt via lazarus ha escrit:



On Wed, 3 Jun 2020, Luca Olivetti via lazarus wrote:


Hello,

I need to embed a simple web server in my application that

1) should server a couple of static files
2) send server-sent events


https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events 




I can see that 1) is easy, but 2) I cannot see how (fpWeb model 
doesn't seem to allow to take over the socket and keep sending data on 
it).
I saw an old message regarding websockets and bauglir-websocket but it 
seems it implements a different server and I'd like to run everything 
from the same socket.


Simply said: You can't in FPC.


It turns out I can with some careful, or reckless ;-),  overriding.

https://paste.ubuntu.com/p/CdHfc7BTHB/


Haha, very nice job :-)

I'll see if I can integrate this in the HTTPServer request/response.

It won't work in fastCGI/CGI of course, but if we can make it available in a
http application, why not...


Michael.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpWeb and server-sent events

2020-06-04 Thread Luca Olivetti via lazarus

El 3/6/20 a les 15:54, Michael Van Canneyt via lazarus ha escrit:



On Wed, 3 Jun 2020, Luca Olivetti via lazarus wrote:


Hello,

I need to embed a simple web server in my application that

1) should server a couple of static files
2) send server-sent events

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events 




I can see that 1) is easy, but 2) I cannot see how (fpWeb model 
doesn't seem to allow to take over the socket and keep sending data on 
it).
I saw an old message regarding websockets and bauglir-websocket but it 
seems it implements a different server and I'd like to run everything 
from the same socket.


Simply said: You can't in FPC.


It turns out I can with some careful, or reckless ;-),  overriding.

https://paste.ubuntu.com/p/CdHfc7BTHB/

Bye

--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


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

2020-06-04 Thread Michael Van Canneyt via lazarus



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
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


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

2020-06-04 Thread Francesco Sammarco via lazarus
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 <
mich...@freepascal.org> 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 <
> > mich...@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 
> 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  >
> >> 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.
> >>
> >
> 
> >>>
> >>
> >
>
-- 

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

2020-06-04 Thread Michael Van Canneyt via lazarus


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 <
mich...@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  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 

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
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


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

2020-06-04 Thread Francesco Sammarco via lazarus
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 <
mich...@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  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 
> 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
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus