-
Notifications
You must be signed in to change notification settings - Fork 68
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
Example for chrono::NaiveDateTime in qs #82
Comments
Did you check what |
Hey @nox thanks for responding! I hope I'm doing this "roundtrip test" correctly:
Playgrounduse serde_urlencoded; // 0.6.1
use chrono::{NaiveDate, NaiveDateTime}; // 0.4.13
fn main() {
// ✅ Good
// let's encode `[("foo", some_naive_date_time)]`
let some_naive_date_time = NaiveDateTime::from_timestamp(1_000_000_000, 0);
assert_eq!(some_naive_date_time, NaiveDate::from_ymd(2001, 9, 9).and_hms(1, 46, 40));
let res = serde_urlencoded::to_string(&[("foo", some_naive_date_time)]);
println!("{:?}", res);
// Ok("foo=2001-09-09T01%3A46%3A40")
// "round trip" fails! 😭
let qs = "foo=2001-09-09T01%3A46%3A40";
let res = serde_urlencoded::from_str::<Vec<(String, NaiveDate)>>(qs);
println!("{:?}", res);
// Err(Error { err: "trailing input" })
} |
Interesting, will look into that, I guess I have quite some free time right now hah. |
That would be awesome. |
Note that I didn't forget about that but I got laid off so I'm just a bit distracted. :D |
Description
Is there an example of how to pass a
chrono::NaiveDateTime
in a querystring?Here's a sample of what i'm struggling with
Playground
End goal
tokio-postgres
SQL query for date filtering, where the column istimestamp
Something like (which might be absurd, but I'm curious if it's possible)
http://localhost:3000/users/a5f5d36a-6677-41c2-85b8-7578b4d98972/attempts?limit=15&offset=15&start=2020-08-09%2003%3A10%3A07%2E813517&end=2020-08-09%2003%3A10%3A07%2E813517
The text was updated successfully, but these errors were encountered: