aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-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.