-
Notifications
You must be signed in to change notification settings - Fork 0
/
v0_7_0.rs
35 lines (34 loc) · 952 Bytes
/
v0_7_0.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#[cfg(feature = "chrono")]
#[test]
fn test_try_from_timestamp_for_chrono_date_time() -> serde_firestore_value::Result<()> {
use serde_firestore_value::Timestamp;
let timestamp = Timestamp {
seconds: 1_i64,
nanos: 2_i32,
};
let date_time = chrono::DateTime::<chrono::Utc>::try_from(timestamp)?;
assert_eq!(
date_time.to_rfc3339(),
"1970-01-01T00:00:01.000000002+00:00"
);
Ok(())
}
#[cfg(feature = "chrono")]
#[test]
fn test_try_from_chrono_date_time_for_timestamp() -> anyhow::Result<()> {
use serde_firestore_value::Timestamp;
let date_time = chrono::DateTime::<chrono::FixedOffset>::parse_from_rfc3339(
"1970-01-01T00:00:01.000000002+00:00",
)?
.naive_utc()
.and_utc();
let timestamp = Timestamp::try_from(date_time)?;
assert_eq!(
timestamp,
Timestamp {
seconds: 1_i64,
nanos: 2_i32,
}
);
Ok(())
}