aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-06-12 17:13:36 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-06-12 17:13:36 +0200
commit774b88dafb486259eb4ccff5466ec1193f787c6e (patch)
treed323f7a112ec1d9b625803e3a460ab8d32679dfb
parent3951dcbce2f229235b77945b3493524ef970af4f (diff)
downloadevtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.tar.gz
evtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.tar.bz2
evtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.zip
add Log::span
-rw-r--r--src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 5d0d3b6..519d1c4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -794,6 +794,22 @@ impl Log {
pub fn events(&self) -> &[Event] {
&self.events
}
+
+ /// Returns the timespan of the log in milliseconds.
+ ///
+ /// The timespan is the time between the first registered event and the last registered event,
+ /// measured in milliseconds.
+ ///
+ /// Note that this does not necessarily equate to the fight/encounter duration, as arcdps
+ /// starts logging as soon as you enter combat, but some bosses are still invulnerable (e.g.
+ /// Ensolyss). It does however give a good idea and is cheap to compute.
+ ///
+ /// In the rare occassions that a log does not have any events, this function will return 0.
+ pub fn span(&self) -> u64 {
+ let first = self.events().first().map(Event::time).unwrap_or(0);
+ let last = self.events().last().map(Event::time).unwrap_or(0);
+ last - first
+ }
}
/// Convenience data accessing funtions for [`Log`][Log]s.