电子表格附加清单时区

时间:2018-09-17 20:01:19

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

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

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

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

1 个答案:

答案 0 :(得分:0)

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

 <select id="dates-field2" class="multiselect-ui form-control" name="RepairType[]" multiple="multiple"> </select>



    $ProductId=$_REQUEST["ProductId"];
    $Qty=$_REQUEST["Qty"];
    $ProdSrlNo=$_REQUEST["ProdSrlNo"];
    $Purpose=$_REQUEST["Purpose"];
    $RepairType=implode(",", $_REQUEST["RepairType"]);
    $Status='Act';          

    $items = array();

    $size = count($ProductId);

    for($i = 0 ; $i < $size ; $i++){
        // Check for part id
        $items[] = array(
            "ProductId"    => $ProductId[$i],
            "Qty"       => $Qty[$i],
            "ProdSrlNo"     => $ProdSrlNo[$i], 
            "Purpose"    => $Purpose[$i],
             "RepairType"       => $RepairType[$i],
             "Status"       => $Status,
        );
    }

    if (!empty($items)) {
        $values = array();
        foreach($items as $item){
            $values[] = "( '{$item['ProductId']}', '{$item['Qty']}', '{$item['ProdSrlNo']}', '{$item['Purpose']}', '{$item['RepairType']}', '{$item['Status']}')";
        }
        $values = implode(", ", $values);
        $sql = "INSERT INTO `product` (`ProductId`,  `Qty`, `ProdSrlNo`, `Purpose`, `RepairType`, `Status`) VALUES  {$values} ";
    }

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

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