Spreadsheet add-on manifest Timezone

Viewed 540

So I want my addon to use users timezone in its functions, how do I set it in manifest?

{
  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.readonly",
    "https://www.googleapis.com/auth/gmail.send",
    "https://www.googleapis.com/auth/spreadsheets",
    "https://www.googleapis.com/auth/script.container.ui",
    "https://www.googleapis.com/auth/script.scriptapp",
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/script.storage"
  ],
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "timeZone": "GMT"
}

I mean addon might be used by users from US or India and they should run addon with their timezone.

1 Answers

You only need the following scope in the manifest file for retrieving the user's timezone.

https://www.googleapis.com/auth/spreadsheets

Then use the SpreadsheetApp service to get the default timezone of the current spreadsheet which is likely the timezone of the user as well.

var ss = SpreadsheetApp.getActiveSpreadsheet();
Logger.log(ss. getSpreadsheetTimeZone());
Related