Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upissue #361 fixed #365
Conversation
budziq
requested changes
Nov 12, 2017
src/basics.md
Outdated
| @@ -1266,6 +1267,37 @@ fn main() { | |||
| } | |||
| ``` | |||
|
|
|||
| [ex-convert-datetime-timestamp]: #ex-convert-datetime-timestamp | |||
| <a name="ex-convert-datetime-timestamp"></a> | |||
| ## Converting date to unix timestamp and vice versa | |||
This comment has been minimized.
This comment has been minimized.
budziq
Nov 12, 2017
Collaborator
- Please use imperative form instead of continuous one in the example title.
s/Converting/Convert/ - UNIX is all caps
src/basics.md
Outdated
| @@ -1423,8 +1455,12 @@ fn main() { | |||
| [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html | |||
| [`MutexGuard`]: https://doc.rust-lang.org/std/sync/struct.MutexGuard.html | |||
| [`NaiveDate`]: https://docs.rs/chrono/*/chrono/naive/struct.NaiveDate.html | |||
| [`NaiveDate::from_ymd`]: https://docs.rs/chrono/0.4.0/chrono/naive/struct.NaiveDate.html#method.from_ymd | |||
This comment has been minimized.
This comment has been minimized.
src/basics.md
Outdated
| [`NaiveDateTime`]: https://docs.rs/chrono/*/chrono/naive/struct.NaiveDateTime.html | ||
| [`NaiveDateTime::from_timestamp`]: https://docs.rs/chrono/0.4.0/chrono/naive/struct.NaiveDateTime.html#method.from_timestamp |
This comment has been minimized.
This comment has been minimized.
budziq
Nov 12, 2017
Collaborator
- please use wildcard version number
- please keep link defs within a single line
src/basics.md
Outdated
| [`NaiveTime`]: https://docs.rs/chrono/*/chrono/naive/struct.NaiveTime.html | ||
| [`NaiveTime::from_hms`]: https://docs.rs/chrono/0.4.0/chrono/naive/struct.NaiveTime.html#method.from_hms |
This comment has been minimized.
This comment has been minimized.
src/basics.md
Outdated
| fn main() { | ||
| let date_time: NaiveDateTime = NaiveDate::from_ymd(2017, 11, 12).and_hms(17, 33, 44); | ||
| let seconds_since_date_time: i64 = date_time.timestamp(); |
This comment has been minimized.
This comment has been minimized.
budziq
Nov 12, 2017
Collaborator
- type ascription is not required here.
- Also the variable name is incorrect. its seconds between UNIX Epoch and the date_time. Lets just drop the intermediate variable and call
timestampwithin the println body
src/basics.md
Outdated
| "Number of seconds between 1970-01-01 00:00:00 and {} is {}.", | ||
| date_time, seconds_since_date_time); | ||
| let billion_seconds: i64 = 1_000_000_000; |
This comment has been minimized.
This comment has been minimized.
src/basics.md
Outdated
| let billion_seconds: i64 = 1_000_000_000; | ||
| let date_time_after_a_billion_seconds = NaiveDateTime::from_timestamp(billion_seconds, 0); | ||
| println!( | ||
| "Date after a billion seconds from 1970-01-01 00:00:00 was {}.", |
This comment has been minimized.
This comment has been minimized.
src/basics.md
Outdated
| } | ||
| ``` | ||
|
|
||
|
|
||
| [ex-format-datetime]: #ex-format-datetime |
This comment has been minimized.
This comment has been minimized.
src/basics.md
Outdated
| [![chrono-badge]][chrono] [![cat-date-and-time-badge]][cat-date-and-time] | ||
|
|
||
| Converts a date given by [`NaiveDate::from_ymd`] and [`NaiveTime::from_hms`] | ||
| to the number of seconds since January 1, 1970 0:00:00 UTC using [`NaiveDateTime::timestamp`]. |
This comment has been minimized.
This comment has been minimized.
budziq
Nov 12, 2017
Collaborator
I'd suggest mentioning hyperlinked keywords such as UNIX and Timestamp
budziq
reviewed
Nov 15, 2017
src/basics.md
Outdated
| Converts a date given by [`NaiveDate::from_ymd`] and [`NaiveTime::from_hms`] | ||
| to [UNIX timestamp] using [`NaiveDateTime::timestamp`]. | ||
| Then it calculates what was the date after one billion seconds | ||
| since [UNIX timestamp], using [`NaiveDateTime::from_timestamp`]. |
This comment has been minimized.
This comment has been minimized.
budziq
Nov 15, 2017
Collaborator
since [UNIX timestamp],
UNIX Timestamp itself is number of seconds since UNIX Epoch to this statement should be:
"Then it calculates what was the date after one billion seconds since [UNIX Epoch]" or "since 1970-01-01 00:00:00" as was previously.
This comment has been minimized.
This comment has been minimized.
budziq
requested changes
Nov 15, 2017
pduzinki
added some commits
Nov 15, 2017
budziq
merged commit e668fff
into
rust-lang-nursery:master
Nov 16, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks @pduzinki ! |
This comment has been minimized.
This comment has been minimized.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
pduzinki commentedNov 12, 2017
•
edited
fixes #361