Skip to content

chrono Date<Utc>.format("%s") panics with unclear message #575

@doivosevic

Description

@doivosevic

panics with panicked at 'a Display implementation returned an error unexpectedly: Error', /build/rustc-1.51.0-src/library/alloc/src/string.rs:2213:14

I feel like there should be a better panic for this case and I guess some other format values have similar panics. This is especially problematic since format doesn't return Result so I wouldn't expect this to panic nor can I handle it gracefully

#[test]
fn test_format_timestamp_chrono() {
    let now = Utc::now().date(); // just Date panics on %s
    now.format("%s").to_string();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions