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

Add example for parsing into chrono::DateTime #351

Closed

Conversation

Projects
None yet
2 participants
@hegza
Copy link
Contributor

hegza commented Oct 29, 2017

Add an example for parsing strings in different formats into chrono::DateTime structs.

See also: #324

@budziq
Copy link
Collaborator

budziq left a comment

@hegza Very nice, the PR is almost perfect!

Just few suggestions below:

[`DateTime::parse_from_str`] respectively. Escape sequences that are available
for the [`DateTime::parse_from_str`] can be found at
[`chrono::format::strftime`]. Note that the [`DateTime::parse_from_str`]
requires that such a DateTime struct must be creatable that it uniquely

This comment has been minimized.

@budziq

budziq Oct 31, 2017

Collaborator

I would also introduce the Naive{Data, Time, DateTime} family here https://docs.rs/chrono/*/chrono/struct.DateTime.html?search=parse_from_str these are less restrictive in regard to the user input (allow for only date and only time without timezone)

[RFC 2822], [RFC 3339], and a custom format, using
[`DateTime::parse_from_rfc2822`], [`DateTime::parse_from_rfc3339`], and
[`DateTime::parse_from_str`] respectively. Escape sequences that are available
for the [`DateTime::parse_from_str`] can be found at

This comment has been minimized.

@budziq

budziq Oct 31, 2017

Collaborator

We might want to split it into two paragraphs (at least the part about escape sequences)

@hegza

This comment has been minimized.

Copy link
Contributor Author

hegza commented Oct 31, 2017

Extended based on feedback. Is this what we are going after? Do comment if there's still something missing.

found at [`chrono::format::strftime`]. Note that the [`DateTime::parse_from_str`]
requires that such a DateTime struct must be creatable that it uniquely
identifies a date and a time. For parsing dates and times without timezones, see
[`NaiveDate::parse_from_str`], [`NaiveTime::parse_from_str`], and

This comment has been minimized.

@budziq

budziq Oct 31, 2017

Collaborator

I would suggest to also use these functions in the actual code and just mention here about the types NaiveDate
/ Naivetime / NaiveDateTime

This comment has been minimized.

@budziq

budziq Oct 31, 2017

Collaborator

Is this what we are going after?

Pretty much. 👍 Just the last nit listed above.

@hegza hegza force-pushed the hegza:feature/chrono-from-input branch 2 times, most recently from 2e4df5e to 78da090 Oct 31, 2017

@hegza

This comment has been minimized.

Copy link
Contributor Author

hegza commented Oct 31, 2017

Should be it. I noticed the PR-template as well and checked all things and squashed the commits in accordance with that.

Henri Lunnikivi
Add example for parsing into chrono::DateTime
- Add an example for parsing strings in different formats into chrono::DateTime
structs and chrono::Naive* structs
- Add links to chrono::*

See also: #324

@hegza hegza force-pushed the hegza:feature/chrono-from-input branch from 78da090 to 64b7117 Oct 31, 2017

@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Nov 3, 2017

Merged! Thanks @hegza !

@budziq budziq closed this Nov 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.