Skip to content

Commit 57be173

Browse files
committed
#19 use chrono::Duration instead of u32 for play duration
1 parent 088ce22 commit 57be173

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/parse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Entry {
4040
#[serde(skip_deserializing)]
4141
platform: String,
4242
/// Miliseconds the song has been played for
43-
ms_played: u32,
43+
ms_played: i64,
4444
/// Skipped
4545
#[serde(skip_deserializing)]
4646
conn_country: (),
@@ -151,7 +151,7 @@ fn entry_to_songentry(entry: Entry) -> Result<SongEntry, PodEntry> {
151151
}
152152
Ok(SongEntry {
153153
timestamp: parse_date(&entry.ts),
154-
ms_played: entry.ms_played,
154+
time_played: chrono::Duration::milliseconds(entry.ms_played),
155155
track: parse_option(entry.master_metadata_track_name),
156156
album: parse_option(entry.master_metadata_album_album_name),
157157
artist: parse_option(entry.master_metadata_album_artist_name),

src/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::error::Error;
44
use std::fmt::Display;
55

6-
use chrono::DateTime;
6+
use chrono::{DateTime, Duration};
77
use chrono_tz::Tz;
88

99
use crate::display;
@@ -163,7 +163,7 @@ pub struct SongEntry {
163163
/// the time at which the song has been played
164164
pub timestamp: DateTime<chrono_tz::Tz>,
165165
/// for how long the song has been played
166-
pub ms_played: u32,
166+
pub time_played: Duration,
167167
/// name of the song
168168
pub track: String,
169169
/// name of the album

0 commit comments

Comments
 (0)