Skip to content

Commit 29abc38

Browse files
jesse99brson
authored andcommitted
---
yaml --- r: 39021 b: refs/heads/incoming c: 2c0dab0 h: refs/heads/master i: 39019: 8cb92d5 v: v3
1 parent 4f30e4b commit 29abc38

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
9-
refs/heads/incoming: c58951ea7d70bfab8c9a0a3ad6540d829c59b585
9+
refs/heads/incoming: 2c0dab02ad64e581ede4344401dca0db67430897
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libstd/time.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl Tm : Eq {
107107
pure fn ne(other: &Tm) -> bool { *self != *(*other) }
108108
}
109109

110-
pub fn empty_tm() -> Tm {
110+
pub pure fn empty_tm() -> Tm {
111111
Tm_({
112112
tm_sec: 0_i32,
113113
tm_min: 0_i32,
@@ -151,13 +151,17 @@ pub fn now() -> Tm {
151151
}
152152

153153
/// Parses the time from the string according to the format string.
154-
pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
155-
do_strptime(s, format)
154+
pub pure fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
155+
// unsafe only because do_strptime is annoying to make pure
156+
// (it does IO with a str_reader)
157+
unsafe {do_strptime(s, format)}
156158
}
157159

158160
/// Formats the time according to the format string.
159-
pub fn strftime(format: &str, tm: Tm) -> ~str {
160-
do_strftime(format, tm)
161+
pub pure fn strftime(format: &str, tm: Tm) -> ~str {
162+
// unsafe only because do_strftime is annoying to make pure
163+
// (it does IO with a str_reader)
164+
unsafe {do_strftime(format, tm)}
161165
}
162166

163167
impl Tm {
@@ -186,18 +190,18 @@ impl Tm {
186190
* Return a string of the current time in the form
187191
* "Thu Jan 1 00:00:00 1970".
188192
*/
189-
fn ctime() -> ~str { self.strftime(~"%c") }
193+
pure fn ctime() -> ~str { self.strftime(~"%c") }
190194
191195
/// Formats the time according to the format string.
192-
fn strftime(format: &str) -> ~str { strftime(format, self) }
196+
pure fn strftime(format: &str) -> ~str { strftime(format, self) }
193197
194198
/**
195199
* Returns a time string formatted according to RFC 822.
196200
*
197201
* local: "Thu, 22 Mar 2012 07:53:18 PST"
198202
* utc: "Thu, 22 Mar 2012 14:53:18 UTC"
199203
*/
200-
fn rfc822() -> ~str {
204+
pure fn rfc822() -> ~str {
201205
if self.tm_gmtoff == 0_i32 {
202206
self.strftime(~"%a, %d %b %Y %T GMT")
203207
} else {
@@ -211,7 +215,7 @@ impl Tm {
211215
* local: "Thu, 22 Mar 2012 07:53:18 -0700"
212216
* utc: "Thu, 22 Mar 2012 14:53:18 -0000"
213217
*/
214-
fn rfc822z() -> ~str {
218+
pure fn rfc822z() -> ~str {
215219
self.strftime(~"%a, %d %b %Y %T %z")
216220
}
217221

@@ -221,7 +225,7 @@ impl Tm {
221225
* local: "2012-02-22T07:53:18-07:00"
222226
* utc: "2012-02-22T14:53:18Z"
223227
*/
224-
fn rfc3339() -> ~str {
228+
pure fn rfc3339() -> ~str {
225229
if self.tm_gmtoff == 0_i32 {
226230
self.strftime(~"%Y-%m-%dT%H:%M:%SZ")
227231
} else {

0 commit comments

Comments
 (0)