Skip to content

Commit e7c83ce

Browse files
authored
Merge pull request #652 from staktrace/sign
Make Time::sign return a sane value
2 parents ee8551e + 01a6714 commit e7c83ce

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/time.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Time {
4242
/// Return whether the offset was positive or negative. Primarily useful
4343
/// in case the offset is specified as a negative zero.
4444
pub fn sign(&self) -> char {
45-
self.raw.offset as u8 as char
45+
self.raw.sign as u8 as char
4646
}
4747
}
4848

@@ -112,3 +112,16 @@ impl Ord for IndexTime {
112112
me.cmp(&other)
113113
}
114114
}
115+
116+
#[cfg(test)]
117+
mod tests {
118+
use crate::Time;
119+
120+
#[test]
121+
fn smoke() {
122+
assert_eq!(Time::new(1608839587, -300).seconds(), 1608839587);
123+
assert_eq!(Time::new(1608839587, -300).offset_minutes(), -300);
124+
assert_eq!(Time::new(1608839587, -300).sign(), '-');
125+
assert_eq!(Time::new(1608839587, 300).sign(), '+');
126+
}
127+
}

0 commit comments

Comments
 (0)