Skip to content

Commit e384341

Browse files
gloaysaryanccn
andauthored
fix: normalize decimal separator when parsing track duration (#214)
Co-authored-by: Ryan Cao <[email protected]>
1 parent 2e58f75 commit e384341

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

src/cmd/discord/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async fn update_presence(client: &mut DiscordIpcClient, state: &mut ActivityStat
6363
return Ok(());
6464
}
6565

66-
let position = position.parse::<f64>()?;
66+
let position = position.replace(',', ".").parse::<f64>()?;
6767

6868
let track = music::get_current_track()
6969
.await?

src/cmd/now.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async fn update_state(
9898
.map(|s| s.trim().to_owned());
9999

100100
let player_position = player_position
101+
.replace(',', ".")
101102
.parse::<f64>()
102103
.ok()
103104
.map(|p| p + time_latency);

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ async fn concise_now_playing() -> Result<()> {
116116
.next()
117117
.ok_or_else(|| eyre!("Could not obtain track duration"))?
118118
.to_owned()
119+
.replace(',', ".")
119120
.parse::<f64>()?;
120121

121122
println!(

src/music/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ pub async fn get_current_track() -> Result<Option<Track>> {
161161
.next()
162162
.ok_or_else(|| eyre!("Could not obtain track duration"))?
163163
.to_owned()
164+
.replace(',', ".")
164165
.parse::<f64>()?;
165166

166167
Ok(Some(Track {

0 commit comments

Comments
 (0)