Skip to main content


Newbie #Rust question time:

I wan to use the current_local_offset function from the time library, but I apparently need to import it into my project with the local-offset feature.

I assume I need to specify this in Cargo.toml but for the life of me, I can't figure out how. Can someone point me in the right direction?

#rust

reshared this

in reply to Jonathan Lamothe

You need to specify the `features` list next to the version in Cargo.toml:

https://doc.rust-lang.org/cargo/reference/features.html#dependency-features

Alternatively, you can run

`cargo add -F FEATURE1,FEATURE2,…`

You can run `cargo add` even after you added a dependency.

in reply to Jonathan Lamothe

Have you tried something like the following?

time = { version = "0.3.36", features = ["local-offset"] }

in reply to glyn

@underlap ^^ this is what is necessary (speaking as the maintainer)
@glyn

This website uses cookies. If you continue browsing this website, you agree to the usage of cookies.