Hacker Newsnew | past | comments | ask | show | jobs | submit | jgilchrist's commentslogin

  "2014-11-28T21:00:09+09:00".parse::<DateTime<FixedOffset>>()
With chrono, I think that's all you need. If you want to name the timezone you can use chrono-tz:

  let tz: Tz = "Europe/London".parse().unwrap()
  let date = "2014-11-28T21:00:09Z".parse::<DateTime<Utc>>().with_timezone(&UTC)


That is indeed what I found :)

But trying to find stuff like this with Rust's documentation-- when you're using a search engine instead of relying on having a human to interpret the question for you-- is usually tremendously frustrating. My experience has been that Rust developers lean heavily on autogenerated documentation, where each method of a struct/enum is heavily documented but there are few to no examples or "E2E scenario" explanations to get you started from scratch.

That's why the above scenario took me an hour: first I had to discover chrono, then a while to realize it wouldn't do what I needed and actually had to use chrono_tz, then a while longer to find where the documentation for time format strings live, etc. All the methods were documented just fine, but there was no high-level explanation leading to them.


When I just did the search for C#, the first non-StackOverflow link was to Microsoft's autogenerated documentation. Without any examples, I'm not sure whether System.DateTime.Parse does what you want. Where would you have looked to get those examples/E2E scenarios for C#?



Interesting. I found https://msdn.microsoft.com/en-us/library/system.datetime(v=v... and there in the long list of methods is a link to https://msdn.microsoft.com/en-us/library/1k1skd40(v=vs.110).... , which doesn't have the example.


.NET allows for function overloading, so usually the examples tend to be on the same page where all variants get listed, not on every single one.

With the main page for a class listing the most common use cases.


Did you look at the READMEs of those libraries? Most of the common use cases are documented fairly comprehensively there - I pulled those examples almost directly out of those documents


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: