Skip to content

Commit

Permalink
Merge pull request #652 from staktrace/sign
Browse files Browse the repository at this point in the history
Make Time::sign return a sane value
  • Loading branch information
ehuss authored Dec 26, 2020
2 parents ee8551e + 01a6714 commit e7c83ce
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Time {
/// Return whether the offset was positive or negative. Primarily useful
/// in case the offset is specified as a negative zero.
pub fn sign(&self) -> char {
self.raw.offset as u8 as char
self.raw.sign as u8 as char
}
}

Expand Down Expand Up @@ -112,3 +112,16 @@ impl Ord for IndexTime {
me.cmp(&other)
}
}

#[cfg(test)]
mod tests {
use crate::Time;

#[test]
fn smoke() {
assert_eq!(Time::new(1608839587, -300).seconds(), 1608839587);
assert_eq!(Time::new(1608839587, -300).offset_minutes(), -300);
assert_eq!(Time::new(1608839587, -300).sign(), '-');
assert_eq!(Time::new(1608839587, 300).sign(), '+');
}
}

0 comments on commit e7c83ce

Please sign in to comment.