Skip to content

Commit

Permalink
refactor(services/integration): change where we perform conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Jan 23, 2025
1 parent 82112fc commit f72f2d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/services/integration/src/yank/youtube_music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ fn get_end_of_day(date: NaiveDate) -> NaiveDateTime {
date.and_hms_opt(23, 59, 59).unwrap()
}

fn get_offset(timezone: &String) -> i32 {
fn get_offset(timezone: &String) -> i16 {
let utc_now = Utc::now();
let parsed = timezone.parse::<Tz>().unwrap();
let local_time = utc_now.with_timezone(&parsed);
local_time.offset().fix().local_minus_utc() / 60
let offset = local_time.offset().fix().local_minus_utc() / 60;
offset.try_into().unwrap()
}

// DEV: Youtube music only returns one record regardless of how many time you have listened
Expand All @@ -50,7 +51,7 @@ pub async fn yank_progress(

let client = RustyPipe::builder()
.storage_dir(TEMP_DIR)
.timezone(&timezone, get_offset(&timezone).try_into().unwrap())
.timezone(&timezone, get_offset(&timezone))
.build()
.unwrap();
client.user_auth_set_cookie(auth_cookie).await?;
Expand Down

0 comments on commit f72f2d8

Please sign in to comment.