【问题标题】:Spreadsheet add-on manifest Timezone电子表格插件清单时区
【发布时间】:2018-09-17 20:01:19
【问题描述】:

所以我希望我的插件在其功能中使用用户时区,如何在清单中设置它?

{
  "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"
}

我的意思是,来自美国或印度的用户可能会使用插件,他们应该使用他们的时区运行插件。

【问题讨论】:

  • 如果您想使用 Google Apps 脚本修改 Manifests 文件 (appsscript.json),使用这个库怎么样? github.com/tanaikech/ManifestsApp如果这不是你想要的,我很抱歉。

标签: google-apps-script timezone manifest.json


【解决方案1】:

您只需要清单文件中的以下范围即可检索用户的时区。

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

然后使用 SpreadsheetApp 服务获取当前电子表格的默认时区,这可能也是用户的时区。

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

【讨论】:

  • 阿米特,感谢您的回复,我了解如何从您的评论中获取时区,但是您如何设置它并覆盖清单时区?这就是我要求的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
相关资源
最近更新 更多