Thursday 15 March 2012

google apps script - How to use timeZone of calendar to set timeZone for date object -


I want to use the calendar timezone to set the time zone of the date object. I am looking for proper technology We have many bases around the country, and each has its own calendar for journal and daily activities. There are many of our scripts that post on the calendar. I want to use the calendar timezone to set the date object time zone, because users travel around different bases, and their computers can not be set to the right time zone, we want to avoid wrong timing settings.

  1. Does the script's timezone be set to UTC?

  2. This is where I am currently: Function submits UITT (e) {var app = UiApp.getActiveApplication (); Var cal = CalendarApp.getCalendarById ('CalendarID'); Var timezone = cal.getTimeZone (); Var ss = SpreadsheetApp.getActiveSpreadsheet (); Var Letter = ss.getSheetByName ('Sheet1'); Var startTime = e.parameter.startDate startTime.setHours (e.parameter.startHour, e.parameter.startmin, 0) startTime = formatTime (starttime, time zone); Logger.log (startTime) var endtime = e.parameter.endDate endTime.setHours (e.parameter.endHour, e.parameter.endMin, 0); Endtime = formatting (end time, timezone); Logger.log (endime) cal.createEvent ('timezone test', new date (starttime), new date (end time)); Ss.appendRow ([startTime, endtime]); Return app; } Function Format Time (Time, Timezone) {Return Utilities.Format (Time, (Timezone-TimeGetMonthon Offset), 'M / D / YY HH: MM'); Edit: Currently there are 3 calendars, they are not user calendars, only for individual air stations. A different calendar has been created. Air stations are each in different time zones, since the crew members have worked at these stations, they post daily activities for the calendar, and there are many u scripts that we have before the same calendar. . A flight log When an entry is posted on any calendar in any calendar, the time is only related to the timezone set on the scheme, not the time zone on the calendar. When the date or timestamp object is created, how can I use the time the calendar itself has been set up.

    What is the best practice for scripts that have been recorded for different time zones? Set the script timezone in UTC and do the conversion? What do you use to get a user's timezone or in this case, I do not care what the user's time zone is also set, I need to use the timezone of the calendar.

    Date, datestring, scriptTimeZone, sessionTz; Var testMonth = "march", testDayOfMnth = "26", testYr = "2016", hour = "10:00", time ZoneDiff = 0; Logger.log ("script time zone:" + session .getScriptTimeZone ()); DateString = testMonth + "+ testDayOfMnth +", "+ testYr; Logger.log (" datestrings: "+ datrustring); date = new date (date string); calories = CalendarApp.getDefaultCalendar (); CalTimeZone = cal.getTimeZone ( ); CalTimJon = Utilities Format (Date, CalTimejone, 'Z'); ScriptTimeGen = Utilities Format (Date, Session, Gate Time Zone (), 'Z'); Calgary = Number (CalTimezone, Salis (0,3) ); SessionTz = Number (ScriptTimJon.Solis (0,3)); // If both time zones are equal signs, then two / two Find the difference between 4 and -2 is the difference 2 / / If each time zone is a different mark, then add absolute values ​​together. - should be between -4 and +1 5 (CALTUS & lt; 0 & amp; ; Amp; amp; amp; amp; semester;> 0; celts & gt; 0 & amp; amp; amp; session; session & lt; 0) {timeZoneDiff = Math.abs (Math.Calitz) + Math. BAS (session tees);} other {timeZoneDiff = Math.abs (mathematics.babs (calculats) - Math.Seb (session)); hour = number (hour slice (0,2)); return time + TimezoneDiff;};

    No comments:

    Post a Comment