mozilla/rust — pull request #2125 by erickt (2012-04-04 17:38:21+00:00)
Title: fleshing out time.rs

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](http://userguide.icu-project.org/formatparse/datetime), [C#](http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx), [java](http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html) or [go](http://golang.org/pkg/time/#constants) does time string formatting.