Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
Importing Google Calendar into Google Sheets and Account for Daylight Savings Time

I copied some code from this website so I can import a google calendar into google sheets. I am not a programmer, I know just enough to be dangerous. I am wondering if there is a line(s) of code that can be added to the script below that will account for Daylight Savings Time.

I live in the Central Time Zone (Missouri). My computer is set to Central Time Zone-Chicago. Now that DST is here, all the times that are imported from Google Calendar into Google Sheets are 1 hour behind what they actually show in Google Calendar. Is there a line(s) of code that can be added to this script to account for DST and pull in the correct times? Any help is greatly appreciated. Thanks, Eric

function importGoogleCalendar() {
var sheet = SpreadsheetApp.getActiveSheet();
var calendarId = sheet.getRange('B1').getValue().toString();
var calendar = CalendarApp.getCalendarById(calendarId);

// Set filters
var startDate = sheet.getRange('B2').getValue();
var endDate = sheet.getRange('B3').getValue();
var searchText = '';

// Print header
var header = [["Title", "Location", "Start", "End", "Duration"]];
var range = sheet.getRange("A6:E6");
range.setValues(header);
range.setFontWeight("bold")

// Get events based on filters
var events = (searchText == '') ? calendar.getEvents(startDate, endDate) : calendar.getEvents(startDate, endDate, {search: searchText})

// Display events
for (var i=0; i<events.length; i++) {
var row = i+7;

var details = [[events[i].getTitle(), events[i].getLocation(), events[i].getStartTime(), events[i].getEndTime(), '']];

range = sheet.getRange(row,1,1,5);
range.setValues(details);

/ Format the Start and End columns
var cell = sheet.getRange(row, 3);
cell.setNumberFormat('mm/dd/yyyy hh:mm');
cell = sheet.getRange(row, 4);
cell.setNumberFormat('mm/dd/yyyy hh:mm');

// Fill the Duration column
cell = sheet.getRange(row, 5);
cell.setFormula('=(HOUR(D' + row + ')+(MINUTE(D' +row+ ')/60))-(HOUR(C' +row+ ')+(MINUTE(C' +row+ ')/60))');
cell.setNumberFormat('0.00');
}
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Check your script timezone.

To do that, go to settings in your script editor (select the gear on the left hand side) and active the third checkbox. Return to the script editor and edit appsscript.json. Change as needed the time zone (America/Chicago).

enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda