mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-01 08:38:05 +00:00
36aaa50644
* Organize utils into separate files. Fixes #2295 * Moving tests. * Fix test. * Fix test 2
13 lines
374 B
Rust
13 lines
374 B
Rust
use chrono::{DateTime, FixedOffset, NaiveDateTime};
|
|
|
|
pub fn naive_from_unix(time: i64) -> NaiveDateTime {
|
|
NaiveDateTime::from_timestamp_opt(time, 0).expect("convert datetime")
|
|
}
|
|
|
|
pub fn convert_datetime(datetime: NaiveDateTime) -> DateTime<FixedOffset> {
|
|
DateTime::<FixedOffset>::from_utc(
|
|
datetime,
|
|
FixedOffset::east_opt(0).expect("create fixed offset"),
|
|
)
|
|
}
|