I am creating a school project for managing classes, I have a problem with time zones and DST here is my code:
javascript
dejt = new Date(thisYear, 8, day, beginTime, endTime, 0, 0);
dejt.toLocaleString("en-US", {timezone: "Europe/Belgrade"});
And I pass I through some functions until:
javascript
function makeCalendar(name, begin, end, calendar) {
var eventSeries = CalendarApp.getCalendarById(calendar).createEventSeries(
name,
begin,
end,
CalendarApp.newRecurrence()
.addWeeklyRule().interval(2).until(endDate)
);
}
This works well until it hits October 29th after that everything is moved one hour earlier.
How do I manage DST?
EDIT:
After setting script to GMT (No daylight saving) things got more consistent and every date vas +00:00
Logs:
[19-02-12 11:30:15:809 CET] Sun Feb 17 00:00:00 GMT+00:00 2019
[19-02-12 11:30:15:810 CET] Mon Feb 18 00:00:00 GMT+00:00 2019
[19-02-12 11:30:24:051 CET] Mon Sep 03 14:00:00 GMT+00:00 2018
[19-02-12 11:30:24:503 CET] Mon Sep 03 14:50:00 GMT+00:00 2018
Now only problem is that recurring events just change time when daylight savings should be (Not a new bug, it was like this before).
EDIT:
New stuff I found out: If you edit events manually there is time zone box; My script makes it UTC but i can manually edit or remove it. Problem here is that I need to do it manually.
I also found .setTimeZone(string) in Google documentation: here, and here
The problem now is that i cannot make it work, no matter what i tried events would and up as UTC