为什么我的 Cron Scheduled Cloud Function for Firebase 运行 是太平洋时间而不是 UTC?

Why is my Cron Scheduled Cloud Function for Firebase running on Pacific time rather than UTC?

我有一个预定的云功能(使用 Google's new solution),它意味着每周一 运行 12:00am。

export const updateHighScores = functions.pubsub.schedule('0 0 * * 1').onRun((context) => {

    // (code)
    // console.log(‘This code will run every Monday at 12:00 AM UTC’);

});

我期待它在 12:00am UTC 运行;然而,当 UTC 午夜到来时,什么也没有发生。所以我去睡觉了,因为我预定的云功能无法正常工作而感到难过,但我决定继续努力。

但第二天我检查了日志,它似乎确实有效,但它 运行 在 12:00am Pacific 时间而不是。

知道为什么 运行 在太平洋时间午夜而不是 UTC 吗?

(我将通过更改所有这些变量并观察它如何影响计划的云功能来进行大量猜测和检查,但我想如果有人他们都知道。谢谢!)

Scheduled functions are triggered on a scheduled by Google Cloud Scheduler. When deploying with the Firebase CLI, the entry in Cloud Scheduler is automatically created for you. If you click through to the Cloud console to show your schedules,您会看到时区设置为 "America/Los_Angeles",即 PST。

时区是使用函数构建器设置的 API。您可以在 documentation.

中阅读相关内容

我这样做了

exports.scheduledFunction = functions.pubsub
.schedule("0 4 * * *")
.timeZone("Asia/Baku")
.onRun((context) => {
    groupCustomers.set({});
    tables.set({});
    calledCustomers.set({});
    groups.set({
        A: { name: "Altering", activeOnTablet: false },
        
    });

    return null;
});