diff options
author | Daniel Schadt <kingdread@gmx.de> | 2020-06-12 17:13:36 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2020-06-12 17:13:36 +0200 |
commit | 774b88dafb486259eb4ccff5466ec1193f787c6e (patch) | |
tree | d323f7a112ec1d9b625803e3a460ab8d32679dfb | |
parent | 3951dcbce2f229235b77945b3493524ef970af4f (diff) | |
download | evtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.tar.gz evtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.tar.bz2 evtclib-774b88dafb486259eb4ccff5466ec1193f787c6e.zip |
add Log::span
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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. |