我在 Quartz.net 上处理的时间是几点?

发布于 2024-12-05 14:36:57 字数 161 浏览 0 评论 0原文

我想知道当我设置这样的东西时,

  Trigger trigger = TriggerUtils.MakeDailyTrigger("abc", 5, 00);

我将其设置为凌晨 5:00。这是凌晨 5:00 服务器时间还是 UTC 时间?

I am wondering when I set something like this

  Trigger trigger = TriggerUtils.MakeDailyTrigger("abc", 5, 00);

I am setting it for 5:00am. Is this 5:00am server time or UTC time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

究竟谁懂我的在乎 2024-12-12 14:36:57

它使用 UTC 时间,但是没有正确记录

编辑:实际上看起来两者都用过! 0.9之前的版本使用当地时间,之后的版本使用UTC(source),所以应该是UTC只要您使用的是最新版本。

It uses UTC time, however this is not properly documented.

Edit: actually it looks like it has used both! Versions prior to 0.9 used local time, those after use UTC (source), so it should be UTC as long as you are using a recent version.

三人与歌 2024-12-12 14:36:57

世界标准时间凌晨 5:00。公共 Quartz.NET API 始终期望时间采用 UTC 格式。仅供参考,MakeDailyTrigger 只是 CronTrigger 的快捷方式,格式如下:

string.Format("0 {0} {1} ? * *", minute, hour)

5:00am UTC time. Public Quartz.NET API always expects times in UTC format. Just FYI, MakeDailyTrigger is just a shortcut to CronTrigger with following format:

string.Format("0 {0} {1} ? * *", minute, hour)
冷夜 2024-12-12 14:36:57

我相信,当您在 MakeDailyTrigger 方法中的小时参数中输入一个小时时,Quartz.Net 期望当地时间...Quartz.net 内部会将此时间转换为 UTC,但如果您在小时参数中输入 5,触发器将触发当地时间凌晨 5 点。

试试这个

        Trigger trigger =
            TriggerUtils.MakeDailyTrigger("trigger",5,0);            

        var ttimes = TriggerUtils.ComputeFireTimes(trigger, null, 1);
        foreach (DateTime ttime in ttimes)
        {
            Console.WriteLine(ttime);
            'ttime is in UTC - so for EST, ttime.Hour would be 10AM
            'however ttime.ToLocalTime().Hour would be 5AM
        }

I believe that when you enter an hour in the hour argument in the MakeDailyTrigger method that Quartz.Net is expecting local time...Internally Quartz.net converts this time to UTC, but if you enter 5 in the hour argument the trigger will fire at 5AM local time.

Try this

        Trigger trigger =
            TriggerUtils.MakeDailyTrigger("trigger",5,0);            

        var ttimes = TriggerUtils.ComputeFireTimes(trigger, null, 1);
        foreach (DateTime ttime in ttimes)
        {
            Console.WriteLine(ttime);
            'ttime is in UTC - so for EST, ttime.Hour would be 10AM
            'however ttime.ToLocalTime().Hour would be 5AM
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文