Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-generate timezone data instead of using build.rs #78

Open
BStenfors9119 opened this issue Apr 1, 2021 · 4 comments
Open

Pre-generate timezone data instead of using build.rs #78

BStenfors9119 opened this issue Apr 1, 2021 · 4 comments

Comments

@BStenfors9119
Copy link

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

@neoeinstein
Copy link

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?

@BStenfors9119
Copy link
Author

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

@mleonhard
Copy link

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?

@mleonhard
Copy link

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 ?

@pitdicker pitdicker changed the title Timezones not visible? Pre-generate timezone data instead of using build.rs Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants