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

Please add support for chrono::{Date, DateTime} and friends in addition to "time". #105

Open
keltia opened this issue May 15, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@keltia
Copy link

keltia commented May 15, 2024

After wrestling a bit with clickhouse_rs to extract dates out of a CH table, I find out it is using types from the "time" crate. It would be nice to have support for the different types from the "chrono" crate as well, I find the latter much easier to use.

Have a chrono feature for example, serde already know how to deal with these.

Having

#[derive(Debug, Deserialize, Serialize, Row)]
pub struct Install {
    pub id: u32,
    pub site_id: u32,
    pub antenna_id: u32,
    pub start_at: DateTime<Utc>,
    pub end_at: DateTime<Utc>,
    pub comment: String,
}

would be way easier than my current

#[derive(Debug, Deserialize, Serialize, Row)]
pub struct Install {
    pub id: u32,
    pub site_id: u32,
    pub antenna_id: u32,
    #[serde(with = "clickhouse::serde::time::datetime")]
    pub start_at: OffsetDateTime,
    #[serde(with = "clickhouse::serde::time::datetime")]
    pub end_at: OffsetDateTime,
    pub comment: String,
}

Thanks.

@slvrtrn slvrtrn added the enhancement New feature or request label Jul 29, 2024
@v3xro
Copy link
Contributor

v3xro commented Jul 30, 2024

There's also the jiff crate now as well. Would be happy to contribute support

@loyd
Copy link
Collaborator

loyd commented Aug 18, 2024

This crate should support all three under features, so I'd like to accept PR. Anyway, I'm thinking about moving to jiff for my production code so that it will be implemented eventually anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants