Automatic event creation (google Apps Script) - calendar

I not a IT so sorry if what I say or what I write is stupid things.
So I'm trying to create a script in google app to create with a redundancy.
I have two questions:
how to select the calendar where the event will be created
Is it possible to repeat this event each hour?
Thank you for your help

Mainly, Apps script is strongly related with Javascript. You will need it mainly with such datatypes as Date.
Selecting calendar
Following command returns all calendars in array:
var calendars = CalendarApp.getAllCalendars();
Thus you can access each individual calendar by doing this:
calendars[i] where i any number between 0 and (# of calendars-1)
For example if you want get name of 2nd calendar:
Logger.log('name of 2nd calendar ==>' + calendars[1].getName());
Hourly event
You can make for loop for each hour and calling createEvent(title, startTime, endTime) command
More commands in Google Apps Script Reference
With regards

Related

ICS to uppdate this and future in recurring calendar event

I am trying to programmatically create icalendar events by creating an ICS file and sending them via email to the attendees. I want to be able to create a recurring event, which works fine.
Now I also want to be able to update these events. If I try to update a single occurrence from the whole event series using UID, RECURRENCE-ID and SEQUENCE, it again gets updated fine.
But I am unable to figure a way out to update this and future events. I tried using VALUE=THISANDFUTURE with RECURRENCE-ID but only the event pointed to by RECURRENCE-ID gets updated. I also do not want to go the "delete the series and create two new ones" way because to do that I'd have to send cancellation emails to the ATTENDEES first and then new events' invites.
I came across the property RELATED-TO which might be relevant here but am unable to understand what it does and how to use it to get the result that I want. Can anyone provide me some direction?
Usage according to the RFC5545 specification ( https://datatracker.ietf.org/doc/html/rfc5545#section-3.2.13) is with RANGE, not VALUE
RECURRENCE-ID;RANGE=THISANDFUTURE:19980401T133000Z

CalDav: Invite another calendar as an attendee

Does anybody know if it's possible to add a calendar as an attendee?
Here's the scenario.
User has multiple calendars, a calendar object (i.e. event) is added to calendar 1, but we also want it to show on calendar 2. Equally they might add an event to calendar 1, but only want to share it with calendar 3.
Events will always be on calendar 1, but they will usually need to be shared with 1 other calendar.
And then we want to be able to query calendar 2..n and only see the things to which they are invited.
The difficulty being that all these calendars belong to a single user principle.
All the docs and examples I've seen have an email address for the attendee. Is it possible to use the calendar address or something?
FWIW I'm using SabreDav on PHP.

Is Microsoft Graph API calendarView limited to a single month? How to get all events?

Is Microsoft Graph API calendarView limited to a single month? How can I get all events? Is there some implicit pagination?
I'm first checking the JSON output of events between 2017-01-01 and 2018-12-30:
https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2017-01-01T00:00:00.0000000&endDateTime=2018-12-30T00:00:00.0000000
and list the dates
jq '.value[] .start .dateTime'
"2017-11-22T13:30:00.0000000"
"2017-11-23T14:00:00.0000000"
"2017-11-24T14:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T11:00:00.0000000"
"2017-11-27T14:30:00.0000000"
"2017-11-28T09:00:00.0000000"
"2017-11-29T09:00:00.0000000"
"2017-11-29T14:00:00.0000000"
No calendar events from 12th month of 2017 for example! But I have them!
And then do a similar call for by narrowing the left end of dates range between 2017-12-01 and 2018-12-30, and now I get:
"2017-12-01T12:30:00.0000000"
"2017-12-01T14:00:00.0000000"
"2017-12-04T08:30:00.0000000"
"2017-12-04T12:00:00.0000000"
"2017-12-06T09:00:00.0000000"
"2017-12-06T10:00:00.0000000"
"2017-12-07T13:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T13:00:00.0000000"
I'm confused by List calendarView and List events documentation.
How can I get all of the events in my calendar, the ones that I can clearly see to exist in November and December of 2017, as well as in January, and February of 2018?
Do I have to call this API repeatedly for every month in a year? (I hope there's a single call I can make to get all the events in a year, or two years, after which I can filter, process, etc.)
Difference between list events and list calendarView
When you list events (GET /me/events), you get a non-expanded list of items in the calendar. What that means is that if you have recurring events, you would only get the series master in your results. It would be up to you to read the recurrence pattern and expand the event.
When you list a calendar view (GET /me/calendarview?...), you get an expanded list of items. That means the server does the work to expand any recurring events and build a "view" of your calendar. So in this case if you have a recurring event, instead of getting the series master, you would get one or more occurrences of the series (depending on how many times it repeats in your view window). Because of this expansion work, you must provide a start and end time to put some sort of bounds on the call.
Another way of looking at it is the calendar view is more like what you're used to seeing when you view your calendar in Outlook.
So where's all my events?
I'm not aware of any specific limitation on the size of the window for a calendar view. (Not saying there isn't one, I'm just not aware of it). The more likely explanation is that you're not seeing all the events you expect because all API requests that return collections do have built-in paging. By default, you're limited to 10 items in the response. You should also see in your response an #odata.nextLink, which is the URL you can use to request the next page of results (again, 10 being the default page size). You can increase your page size by using the $top parameter, up to a maximum of 1000 (IIRC).
GET /me/calendar/calendarView?startDateTime=2017-01-01T00:00:00.0000000
&endDateTime=2018-12-30T00:00:00.0000000&$top=1000

Is it possible to prevent an AngularJS app to start during business hours?

Is it possible to prevent an AngularJS app to start during business hours ?
Let's say that I do not want the app to be working between 8h and 18h. During this time, I want to display a page saying that the user must come back at the time left.
If I got your question right, you should do this on the server side.
On business time your webserver is responding with the "please come back later" site and during out of business your webserver could serve your site with angularJS Code.
Yes it's possible.
JavaScript allows to get date, and time using Date object. For example
var date = new Date(); // Will set date variable as current date object
console.log(new Date().getTime()) // Will print time (milliseconds since midnight of January 1, 1970)
You can further process the date using Moment JS library - http://momentjs.com/
Using Moment JS you can extract hour, and minute and set simple boolean variable in scope. Let's name it businessHours.
Then you can create two div elements with ng-show/ng-hide commands:
<div ng-hide='businessHours'>
<!-- application -->
</div>
<div ng-show='businessHours'>
<!-- error message saying that the user must come back at the time left -->
</div>
BUT keep in mind it's very easy to hack. If user simply change hour on his machine the application won't show error message. So this check should be moved to server side code. But it's not Angular matter anymore.
You could do this from angular but you'd need to get the current time from a reliable source, not the client.
Some examples of free api for time check:
https://timezonedb.com/api
http://www.geonames.org/export/ws-overview.html

Google Calendar API - List Event with startDate and EndDate Filter

I can't understand how Google Calender Event List work with timeMin and timeMax parameter.I am using the following statement for filter events. (Used Google Calender V3 API)
service.events().list(calendarId='primary',timeMin=start_dt,timeMax=end_dt)
I have created event from 23-12-2013 to 26-12-2013 without specifying time.
Now when I specified timeMax=2013-12-23T00:00:00+05:30 and timeMin=2013-12-23T00:00:00+05:30 then and only then I have got event in list if I specified timeMin greater than 23 it gives me event['items']=[]. Also not understand timezone.
Can anyone help me to understand this.

Resources