Skip to content

Commit

Permalink
bson timestamps are LE (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-pogliani authored and zonyitoo committed Jul 11, 2018
1 parent 4a19ba6 commit bf3c702
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/decoder/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,12 @@ impl<'de> Deserialize<'de> for TimeStamp {

match Bson::deserialize(deserializer)? {
Bson::TimeStamp(ts) => {
let ts = ts.to_be();
let ts = ts.to_le();

Ok(TimeStamp { t: ((ts as u64) >> 32) as u32,
i: (ts & 0xFFFF_FFFF) as u32, })
}
_ => Err(D::Error::custom("expecting UtcDateTime")),
_ => Err(D::Error::custom("expecting TimeStamp")),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn test_de_timestamp() {
}

let foo: Foo = bson::from_bson(Bson::Document(doc! {
"ts": Bson::TimeStamp(0x0A00_0000_0C00_0000),
"ts": Bson::TimeStamp(0x0000_000C_0000_000A),
})).unwrap();

assert_eq!(foo.ts, TimeStamp { t: 12, i: 10 });
Expand Down

0 comments on commit bf3c702

Please sign in to comment.