Skip to content

Chrono feature in built_time() example on docs.rs #57

@trebinor

Description

@trebinor

An example function built_time() appears for the latest (0.6.1) version of built on docs.rs

#[cfg(feature = "chrono")]
fn built_time() -> built::chrono::DateTime<built::chrono::Local> {
    built::util::strptime(built_info::BUILT_TIME_UTC)
        .with_timezone(&built::chrono::offset::Local)
}

What is the proper way to enable the chrono feature to enable conditional compilation of built_time()? Maybe this cfg is no longer needed, because commenting it out includes the function. Note that that adding this to Cargo.toml has no effect.

[features]
chrono = []

The fix can be tested by adding built_time() before main() in built/example_project/src/main.rs and adding this to main():

    println!("Build time: {:?}", built_time());

You should see that built_time() is not found when the cfg is present, and the build succeeds if it's commented out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions