aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 9ed67cf..133bd2d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,7 +17,7 @@ use structopt::StructOpt;
use walkdir::{DirEntry, WalkDir};
use evtclib::raw::parser::PartialEvtc;
-use evtclib::{Boss, EventKind, Log};
+use evtclib::{Boss, Event, EventKind, Log};
mod fexpr;
mod filters;
@@ -552,17 +552,10 @@ fn extract_info(path: &Path, log: &Log) -> LogResult {
.collect::<Vec<Player>>();
players.sort();
- let duration = log
- .local_end_timestamp()
- .and_then(|end| log.local_start_timestamp().map(|start| end - start))
- .map(|x| x as i64)
- .map(Duration::seconds)
- .unwrap_or_else(Duration::zero);
-
LogResult {
log_file: path.to_path_buf(),
time: Utc.timestamp(i64::from(log.local_end_timestamp().unwrap_or(0)), 0),
- duration,
+ duration: get_fight_duration(log),
boss,
players,
outcome: get_fight_outcome(log),
@@ -599,3 +592,10 @@ fn get_fight_outcome(log: &Log) -> FightOutcome {
FightOutcome::Wipe
}
}
+
+/// Get the duration of the fight.
+fn get_fight_duration(log: &Log) -> Duration {
+ let start = log.events().first().map(Event::time).unwrap_or(0) as i64;
+ let end = log.events().last().map(Event::time).unwrap_or(0) as i64;
+ Duration::milliseconds(end - start)
+}