在Rust中获取本地时区名称的一种方法是使用chrono和chrono-tz库。首先,确保在Cargo.toml文件中添加以下依赖项: 代码语言:txt 复制 [dependencies] chrono = "0.4" chrono-tz = "0.5" 然后,在Rust代码中使用以下代码获取本地时区名称: 代码语言:txt 复制 use chrono::offset::Loca
chrono 关键类型 类型含义适用场景 DateTime<Tz> 一个带有时区的日期和时间类型,其中 Tz 是实现了 TimeZone 特质的类型,如 Utc 和 Local 。这意味着 DateTime 考虑了时区的影响,可以表示全球任意地点的精确时间。 广泛用于需要考虑时区转换的场景,如存储用户的本地时间或在不同地区之间转换时间。 NaiveDateTime 一个...
chrono-tz:为chrono库提供时区支持,基于全世界的IANA时区数据库。 httpdate:用于解析和格式化HTTP日期标头的Rust库。 iana-time-zone:一个用于获取当前系统IANA时区名称的库。 hifitime:一个用于高精度日期和时间计算的库,保留原描述。 cron:用于解析cron语法的解析器和用于时间表达式的库。 humantime:用于解析和格式化...
use chrono::{TimeZone, Utc}; use chrono_tz::US::Pacific; let pacific_time = Pacific.ymd(1990, 5, 6).and_hms(12, 30, 45); let utc_time = pacific_time.with_timezone(&Utc); assert_eq!(utc_time, Utc.ymd(1990, 5, 6).and_hms(19, 30, 45)); Create a naive datetime and co...
usechrono::{Duration,TimeZone};usechrono_tz::Europe::London;usechrono_tz::OffsetComponents;letlondon_time =London.ymd(2016,5,10).and_hms(12,0,0);// London typically has zero offset from UTC, but has a 1h adjustment forward// when summer time is in effect.assert_eq!(london_time.offse...
pub fndate_c(date:&chrono::Date<chrono_tz::Tz>)->gtk::Label{gtk::Label::new(Some(&format!("{}",date.format("%B %e, %Y")))} 当组件实际上是一个很少或甚至从不更新的可视组件时,这种模式就是可行的。在我的应用程序中,日期标签是更大一块显示内容的子组件,因此是永远不变的东西。 具有...
librust-speedate-dev librust-httpdate-dev librust-subtle-dev librust-ct-codecs-dev librust-humantime-dev librust-plotters-dev librust-interim-dev librust-time-tz-dev librust-chrono-english-devDate and time library for Rust - Rust source codeその他の librust-chrono-dev 関連パッケージ依...
chrono-tzIntegrate with thechrono-tzcrate. dataloaderSupportDataLoader. decimalIntegrate with therust_decimalcrate. dynamic-schemaSupport dynamic schema fast_chemailIntegrate with thefast_chemailcrate. graphiqlEnables theGraphiQL IDEintegration hashbrownIntegrate with thehashbrowncrate. ...
"chrono-tz-build", "phf", ] [[package]] name = "chrono-tz-build" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" dependencies = [ "parse-zoneinfo",...
Chrono是一个Rust的日期和时间库,提供了处理公历日期和时间的解决方案。它提供灵活的解析和格式化功能,类似于strftime。Chrono的特点包括alloc、std、clock和wasmbind,还有可选的扩展如serde和rkyv。为了保持核心库的轻量级,默认情况下不包含时区数据,不过可以通过引入Chrono-TZ或tzfile轻松解决。详细的文档可在网站上查阅...