Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,6 @@ pub fn now() -> Tm {
at(get_time())
}

/// Parses the time from the string according to the format string.
pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
do_strptime(s, format)
}

/// Formats the time according to the format string.
pub fn strftime(format: &str, tm: &Tm) -> ~str {
do_strftime(format, tm)
}

impl Tm {
/// Convert time to the seconds from January 1, 1970
Expand Down Expand Up @@ -264,7 +255,8 @@ impl Tm {
}
}

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

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