aboutsummaryrefslogtreecommitdiff
path: root/tool/src/import/tmdb.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tool/src/import/tmdb.rs')
-rw-r--r--tool/src/import/tmdb.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tool/src/import/tmdb.rs b/tool/src/import/tmdb.rs
index 5f21afd..38d6534 100644
--- a/tool/src/import/tmdb.rs
+++ b/tool/src/import/tmdb.rs
@@ -1,3 +1,5 @@
+use anyhow::Context;
+use jellycommon::chrono::{format::Parsed, DateTime, Utc};
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
@@ -93,3 +95,22 @@ pub fn tmdb_image(path: &str, out: &mut impl Write) -> anyhow::Result<()> {
res.copy_to(out)?;
Ok(())
}
+
+pub fn parse_release_date(d: &str) -> anyhow::Result<DateTime<Utc>> {
+ let (year, month, day) = (&d[0..4], &d[5..7], &d[8..10]);
+ let (year, month, day) = (
+ year.parse().context("parsing year")?,
+ month.parse().context("parsing month")?,
+ day.parse().context("parsing day")?,
+ );
+
+ let mut p = Parsed::new();
+ p.year = Some(year);
+ p.month = Some(month);
+ p.day = Some(day);
+ p.hour_div_12 = Some(0);
+ p.hour_mod_12 = Some(0);
+ p.minute = Some(0);
+ p.second = Some(0);
+ Ok(p.to_datetime_with_timezone(&Utc)?)
+}