【问题标题】:How to find the local timezone offset in Rust?如何在 Rust 中找到本地时区偏移量?
【发布时间】:2023-03-31 04:04:01
【问题描述】:

如何在 Rust 中找到本地时区偏移量?有没有一种不用像 Chronos 这样的板条箱就能轻松找到它的方法?

【问题讨论】:

    标签: rust


    【解决方案1】:

    chrono::offset::Local 使用“标准的time crate”,因此您可以根据需要使用它来代替chrono

    UtcOffset::try_current_local_offset() 应该做你需要的。或者try_local_offset_at(),如果您需要按原样、过去或将要在特定时刻的偏移量。

    如果你想要来自std(甚至core)的东西,我认为它不存在。至少不是以独立于平台的方式。

    【讨论】:

      猜你喜欢
      • 2011-01-07
      • 2012-08-14
      • 2021-10-16
      • 1970-01-01
      • 2013-07-17
      • 2013-01-13
      • 2011-04-01
      • 2015-11-10
      • 1970-01-01
      相关资源
      最近更新 更多