samscott89 / serde_qs

Serde support for querystring-style strings
Apache License 2.0
193 stars 67 forks source link

ISO8601 or RFC3339 Formatted Date Time with Time Zone Type Strings #65

Closed IdemenB closed 2 years ago

IdemenB commented 2 years ago

Hi,

I just noticed, when I use serde_qs within Actix4 to capture the query parameters sent with a HTTP request, the crates disposes of plus and minus signs that must be available in date time with TZ strings. Below are two samples.

1996-12-19T16:39:57-08:00

2022-06-29T07:02:50+00:00

I expect to get them as String instances and parse to DateTime using DateTime::parse_from_rfc3339()

samscott89 commented 2 years ago

Hey @IdemenB!

Thanks for opening an issue. I'll respond to this one in favour of #66. Not sure what the distinction is between the two issues.

Can you say more about the behaviour you are seeing? For example, those two string are not valid urlencoded strings, if you straight up deserialize those using serde_qs you will get an error like

thread 'test_improperly_encoded_dates' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("input contains invalid characters")', tests/test_chrono.rs:44:40

You can see what a correctly serialized datetime value looks like here:

https://github.com/samscott89/serde_qs/blob/0c8dc4ae5382af826f6bc52b816dca37e48f7320/tests/test_chrono.rs#L21

Note that : and + are replaced with the percent-encoded values.

IdemenB commented 2 years ago

Hi @samscott89, sorry for opening duplicated issues; I believe the other day I thought the initial was not created successfully. What I see here is that I missed to provide the date string which is in ISO 8601 in the url encoded form. Because that format contains spaces that's how it should be provided. So, this is my bad and there is no issue with the way the crate decodes what is provided.