Skip to content

Commit 4bae639

Browse files
committed
auto merge of #9705 : luisbg/rust/strptime, r=alexcrichton
do_strptime() and do_strftime() I don't see any reason why src/libextra/time.rs has two functions that just call a very similar function, which only use is to be called by them. strftime() just calls do_strftime() strptime() just calls do_strptime() and the do_functions aren't called by anyone else. the parameters and return types are exactly the same in both levels, so I just have removed the second layer. Unless there is a need for that second level.
2 parents 012f909 + a0c5994 commit 4bae639

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/libextra/time.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,6 @@ pub fn now() -> Tm {
174174
at(get_time())
175175
}
176176

177-
/// Parses the time from the string according to the format string.
178-
pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
179-
do_strptime(s, format)
180-
}
181-
182-
/// Formats the time according to the format string.
183-
pub fn strftime(format: &str, tm: &Tm) -> ~str {
184-
do_strftime(format, tm)
185-
}
186177

187178
impl Tm {
188179
/// Convert time to the seconds from January 1, 1970
@@ -264,7 +255,8 @@ impl Tm {
264255
}
265256
}
266257

267-
fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
258+
/// Parses the time from the string according to the format string.
259+
pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
268260
fn match_str(s: &str, pos: uint, needle: &str) -> bool {
269261
let mut i = pos;
270262
for ch in needle.byte_iter() {
@@ -733,7 +725,8 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
733725
}
734726
}
735727

736-
fn do_strftime(format: &str, tm: &Tm) -> ~str {
728+
/// Formats the time according to the format string.
729+
pub fn strftime(format: &str, tm: &Tm) -> ~str {
737730
fn days_in_year(year: int) -> i32 {
738731
if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))) {
739732
366 /* Days in a leap year */

0 commit comments

Comments
 (0)