Skip to content

Commit 0afd15a

Browse files
committed
Store render time as DateTime<FixedOffset>
Since version 0.25.0, PyO3 can't convert `DateTime<Local>` to `PyDateTime` anymore. Because of that we now convert the chrono `DateTime<Local>` to a chrono `DateTime<FixedOffset>`. This fixes the `PyDateTime` conversion, since PyO3 does support converting `DateTime<FixedOffset>`.
1 parent 76d5edf commit 0afd15a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/node/nodeinfo.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::{anyhow, Result};
2+
use chrono::offset::FixedOffset;
23
use chrono::offset::Local;
34
use chrono::DateTime;
45
use pyo3::prelude::*;
@@ -29,8 +30,11 @@ pub struct NodeInfoMeta {
2930
#[pyo3(get)]
3031
pub environment: String,
3132
#[pyo3(get)]
32-
/// `chrono::DateTime<Local>` at which we started rendering the data for the node
33-
render_time: DateTime<Local>,
33+
/// `chrono::DateTime<FixedOffset>` at which we started rendering the data for the node
34+
///
35+
/// When creating the value we convert a `DateTime<Local>` to a `DateTime<FixedOffset> since
36+
/// PyO3 can't convert `DateTime<Local>` to a `PyDateTime` anymore.
37+
render_time: DateTime<FixedOffset>,
3438
}
3539

3640
impl Default for NodeInfoMeta {
@@ -55,7 +59,7 @@ impl NodeInfoMeta {
5559
name: name.into(),
5660
uri: uri.into(),
5761
environment: environment.into(),
58-
render_time: Local::now(),
62+
render_time: Local::now().into(),
5963
}
6064
}
6165

0 commit comments

Comments
 (0)