chrono-tz
chrono-tz copied to clipboard
Pre-generate timezone data instead of using `build.rs`
To Whom This May Concern:
I am still a pretty newbie Rust dev and trying to implement this to convert a UTC time to PST.
I am following the examples but the timezone modules do not show for me. I am apparently doing something wrong.
Here is my Cargo.toml entries:
chrono = { version = "0.4.19", default-features = false }
chrono-tz = { version = "0.5.3", default-features = false }
I am "externing" the crates chrono and chrono_tz in my main and also implementing:
use chrono::{TimeZone, UTC};
And when I try to implement chrono_tz::US::Pacific all I get is the ability to do the following:
use chrono_tz::{OffsetComponents, OffsetName};
What the heck am I missing?
TIA, B
When you say that they do not show for you, do you mean in terms of IDE support showing you all of the information? If so, rest assured that they are all there, but that the IDE may just be having some difficulty understanding how to interpret the build script and macro that generates a lot of the information.
Which IDE are you using?
When you say that they do not show for you, do you mean in terms of IDE support showing you all of the information? If so, rest assured that they are all there, but that the IDE may just be having some difficulty understanding how to interpret the build script and macro that generates a lot of the information.
Which IDE are you using?
Ahhhhhh, didn't even think about that!
I am using Jetbrains CLion
I also hit this and wasted a lot of time on it.
The root cause is that CLion and the intellij-rust
plugin do not run build scripts by default. There are instructions for turning it on in intellij-rust issue #1908. Turning it on has some downsides.
chrono-tz's build.rs
loads the timezone data from the local system and generates Rust code. The library uses an include!
statement in directory.rs
to load the generated code. This takes data from the build machine and includes it in the binary. This is contrary to the standard software engineering practice of using a source code repository to store all inputs of the build process. If chrono_tz
was published with the file already generated, then building it will no longer use data from the build host. I want this behavior. It will also speed up builds and work around the editor visibility problem.
Would the maintainers be amenable to changing chrono_tz
to include a pre-generated directory.rs
file?
I mis-read the code. chrono-tz's build.rs
does not use timezone data from the local system. At chrono-tz-build/src/lib.rs#L426
, it reads files from the tz/
source dir.
I still hope that chrono-tz can include the file pre-generated so builds will be faster and users will not waste time trouble-shooting editor visibility problems.
Maybe we can include the change in #22 ?