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

Cookbook ideas for chrono #324

Closed
j-haj opened this Issue Oct 9, 2017 · 10 comments

Comments

Projects
None yet
5 participants
@j-haj
Copy link
Contributor

j-haj commented Oct 9, 2017

Let's add some recipes for the chrono crate. Feel free to contribute additional examples/ideas or PRs!

  • Display formatted date and time using RFC 2822, RFC 3339, and custom formats
  • Create a DateTime struct from input using RFC 2822, RFC 3339, and custom formats
  • Example showing checked arithmetic using dates
  • Example showing use of functions from the Datelike and Timelike traits such as month, weekday, hour, minute, etc.

@j-haj j-haj referenced this issue Oct 9, 2017

Open

Miscellaneous cookbook ideas #24

6 of 7 tasks complete

@budziq budziq added this to the impl period milestone Oct 9, 2017

@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Oct 9, 2017

Initial ideas by @j-haj
Here are some ideas to start us off:

  • Display formatted date and time using RFC 2822, RFC 3339, and custom formats
  • Create a DateTime struct from input using RFC 2822, RFC 3339, and custom formats
  • Example showing checked arithmetic using dates
  • Example showing use of functions from the Datelike and Timelike traits such as month, weekday, hour, minute, etc.
  • Example showing serialization and deserialization of DateTime using serde Id avoid that example for now as it requires a nondefault crate feature (explicitly enabling "serde" in cargo toml) Lets put it on back-burner for now #324 (comment)

Once we get some attention here, I'll stsrt adding final example ideas to the tracking list.

Thanks a lot @j-haj ! 🥇

@hegza

This comment has been minimized.

Copy link
Contributor

hegza commented Oct 22, 2017

I've done something like what you're describing here @budziq / @j-haj, for both formatting and clocking execution time. Could be cool trying to make them as idiomatic as I can. I believe I'll be able to get back to you with a PR about the three first points later down the week.

@j-haj

This comment has been minimized.

Copy link
Contributor Author

j-haj commented Oct 22, 2017

@hegza Sounds great - can't wait to see the examples!

One thing I noticed the other day is that chrono seems to state that it is not really best used for tracking elapsed time to execute a segment of code:

For more abstract moment-in-time tracking such as internal timekeeping that is unconcerned with timezones, consider time::SystemTime, which tracks your system clock, or time::Instant, which is an opaque but monotonically-increasing representation of a moment in time.

I'm wondering if maybe the first item in our list should be removed. @budziq what are your thoughts?

@hegza

This comment has been minimized.

Copy link
Contributor

hegza commented Oct 23, 2017

Seems so. I would agree with just skipping that first one, since it would be hardly idiomatic to do something that the crate is not supposed to do.

Another question I had in mind was that if the chrono examples should be assigned under some one of the current top-level topics, or if it should be a new topic. It seems that the topics are not trying to be library-by-library, but rather something more abstract. Formatting date-time could certainly be situated in more than just one of the current topics.

@j-haj

This comment has been minimized.

Copy link
Contributor Author

j-haj commented Oct 23, 2017

Another question I had in mind was that if the chrono examples should be assigned under some one of the current top-level topics, or if it should be a new topic.

Excellent question. Probably something for @budziq to chime in on but my intuition is that it makes the most sense to add this to basics section. It may not be super important as it sounds like we may reorganize things in the future.

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 23, 2017

Henri Lunnikivi
Add example for formatting chrono::DateTime
* Add link to date-and-time-badge at badge-cache.kominick.com
* Add link to date-and-time category at crates.io
* Add all necessary document structure related to the aformentioned

See also: rust-lang-nursery#324
@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Oct 24, 2017

@j-haj & @hegza

I'm wondering if maybe the first item in our list should be removed. @budziq what are your thoughts?

Yep this item is a viable example idea but would be std only 👍 - I'll add it to misc/std tracking issue.

Another question I had in mind was that if the chrono examples should be assigned under some one of the current top-level topics, or if it should be a new topic.

Aaron is working on an editorial pass over the cookbook examples including section reorganization. For now lets add it to basics as @j-haj suggests.

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 25, 2017

Henri Lunnikivi
Add example for formatting chrono::DateTime
* Add link to date-and-time-badge at badge-cache.kominick.com
* Add link to date-and-time category at crates.io
* Add all necessary document structure related to the aformentioned

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 25, 2017

Henri Lunnikivi
Review example for formatting chrono::DateTime
* Move comments in related code to textual description
* Remove extra binding in related code

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 25, 2017

Henri Lunnikivi
Add links to example for formatting chrono::DateTime
* Add link to standards RFC 2822 and RFC 3339
* Add link to used methods in chrono

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 26, 2017

Henri Lunnikivi
Add example for formatting chrono::DateTime
* Add link to date-and-time-badge at badge-cache.kominick.com
* Add link to date-and-time category at crates.io
* Add all necessary document structure related to the aformentioned

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 26, 2017

Henri Lunnikivi
Review example for formatting chrono::DateTime
* Move comments in related code to textual description
* Remove extra binding in related code

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 26, 2017

Henri Lunnikivi
Add links to example for formatting chrono::DateTime
* Add link to standards RFC 2822 and RFC 3339
* Add link to used methods in chrono

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 29, 2017

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

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

Henri Lunnikivi
Extend example for parsing into chrono::DateTime
- Split text body to two paragraphs.
- Add links to Naive{Date, Time, DateTime}.

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

Henri Lunnikivi
Add Naive* use cases for parsing into chrono::DateTime
- Add use cases for Naive* variants of chrono's dates and times
- Change Naive* links to point at structs instead of specific methods

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

Henri Lunnikivi
Add Naive* use cases for parsing into chrono::DateTime
- Add use cases for Naive* variants of chrono's dates and times
- Change Naive* links to point at structs instead of specific methods

See also: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

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: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

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: rust-lang-nursery#324

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Oct 31, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 2, 2017

budziq added a commit that referenced this issue Nov 3, 2017

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
@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Nov 3, 2017

Example showing serialization and deserialization of DateTime using serde

For now such example would require a nondefault crate feature (explicitly enabling "serde" in cargo toml). As we have no clear story yet on howto support cargo features (how do we test these, how do we present cargo.toml and how to handle desynchronization with https://play.rust-lang.org/ which does not support crate features) Lets put it on back-burner for now

@ludwigpacifici

This comment has been minimized.

Copy link
Contributor

ludwigpacifici commented Nov 4, 2017

Two additional examples:

  • For a given timezone, convert a local time to UTC and convert UTC time to local time.
  • Convert a formatted date (for example YYYY-MM-DD:HH:MM:SS) to a Unix timestamp. Convert it also the other way around.

Do you think these could be interesting recipes? If you are happy with it, I can open dedicated issues for them.

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 4, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 4, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 4, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 4, 2017

hegza pushed a commit to hegza/rust-cookbook that referenced this issue Nov 4, 2017

@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Nov 4, 2017

@ludwigpacifici

Do you think these could be interesting recipes?

Very cool ideas! Lets go for it 👍

@AndyGauge

This comment has been minimized.

Copy link
Collaborator

AndyGauge commented Apr 23, 2018

As all the proposed ideas are implemented, I'm going to close the tracking issue. If you have additional ideas for Chrono, please feel free to open a new issue. The one outstanding issue mentioned is reorganization. That is definitely in the works.

@AndyGauge AndyGauge closed this Apr 23, 2018

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.