Skip to content

fleshing out time.rs #2125

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

Merged
merged 8 commits into from
Apr 4, 2012
Merged

fleshing out time.rs #2125

merged 8 commits into from
Apr 4, 2012

Conversation

erickt
Copy link
Contributor

@erickt erickt commented Apr 4, 2012

Good morning all,

I finally got my time code to a point where it works on all the platforms. This patch series does a couple things. First, it converts get_time to return {sec: i64, nsec: i32}. I made this change because many systems return negative values for times before 1/1/1970, 64 bit machines can return 64 bit second times, and linux can return subtimes with nanosecond resolution.

Second, I added pure-rust versions of strftime and strptime. The functionality is not complete to the c standard, but it's pretty thorough. I also added some helper functions that generate time strings for generating ctime, rfc822, and rfc 3339 formatted strings.

Please let me know if you have comments or want changes. I'm not completely sold on using strftime formats. It's standard, but you need to look at documentation to decipher what's going on. Perhaps instead we should copy how icu, C#, java or go does time string formatting.

erickt added 8 commits April 3, 2012 22:43
It's possible to have negative times if expressing time before 1970, so
we should use signed types. Other platforms can return times at a higher
resolution, so we should use 64 bits.
This lets us use the more precise clock_gettime on posix
machines.
brson added a commit that referenced this pull request Apr 4, 2012
@brson brson merged commit 3aed498 into rust-lang:master Apr 4, 2012
@brson
Copy link
Contributor

brson commented Apr 4, 2012

Nice work!

celinval pushed a commit to celinval/rust-dev that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants