@@ -107,7 +107,7 @@ impl Tm : Eq {
107
107
pure fn ne ( other : & Tm ) -> bool { * self != * ( * other) }
108
108
}
109
109
110
- pub fn empty_tm ( ) -> Tm {
110
+ pub pure fn empty_tm ( ) -> Tm {
111
111
Tm_ ( {
112
112
tm_sec: 0_i32 ,
113
113
tm_min: 0_i32 ,
@@ -151,13 +151,17 @@ pub fn now() -> Tm {
151
151
}
152
152
153
153
/// 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) }
156
158
}
157
159
158
160
/// 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) }
161
165
}
162
166
163
167
impl Tm {
@@ -186,18 +190,18 @@ impl Tm {
186
190
* Return a string of the current time in the form
187
191
* "Thu Jan 1 00:00:00 1970".
188
192
*/
189
- fn ctime( ) -> ~str { self . strftime ( ~"%c") }
193
+ pure fn ctime ( ) -> ~str { self . strftime ( ~"%c") }
190
194
191
195
/// 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) }
193
197
194
198
/**
195
199
* Returns a time string formatted according to RFC 822.
196
200
*
197
201
* local: " Thu , 22 Mar 2012 07 : 53 : 18 PST "
198
202
* utc: "Thu, 22 Mar 2012 14:53:18 UTC"
199
203
* /
200
- fn rfc822 ( ) -> ~str {
204
+ pure fn rfc822 ( ) -> ~str {
201
205
if self . tm_gmtoff == 0_i32 {
202
206
self . strftime ( ~"%a, %d %b %Y %T GMT ")
203
207
} else {
@@ -211,7 +215,7 @@ impl Tm {
211
215
* local: "Thu, 22 Mar 2012 07:53:18 -0700"
212
216
* utc: "Thu, 22 Mar 2012 14:53:18 -0000"
213
217
*/
214
- fn rfc822z ( ) -> ~str {
218
+ pure fn rfc822z( ) -> ~str {
215
219
self . strftime ( ~"%a, %d %b %Y %T %z")
216
220
}
217
221
@@ -221,7 +225,7 @@ impl Tm {
221
225
* local: "2012-02-22T07:53:18-07:00"
222
226
* utc: "2012-02-22T14:53:18Z"
223
227
*/
224
- fn rfc3339 ( ) -> ~str {
228
+ pure fn rfc3339( ) -> ~str {
225
229
if self . tm_gmtoff == 0_i32 {
226
230
self . strftime ( ~"%Y -%m-%dT%H : %M : %SZ ")
227
231
} else {
0 commit comments