简体   繁体   English

电子表格附加清单时区

[英]Spreadsheet add-on manifest Timezone

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. 我的意思是,来自美国或印度的用户可能会使用插件,因此他们应该在时区运行插件。

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. 然后,使用SpreadsheetApp服务获取当前电子表格的默认时区,该默认时区也可能是用户所在的时区。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM